Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50199

Find TextBox1.Value in another workbook

$
0
0
Hi all

First time posting, so hope I do everything correctly :D

I have 2 workbooks, 1 containing information of different projects and the other workbook contains ressource information.

In the workbook containing Ressource I need a userform with a Textbox(To input Project ID) and a combobox(to choose Status of a project).

I have succes in defining 2 arrays and load the Database workbook, but I can't find any good solution for find ID of project in database workbook and the change the Status of a project.

Hope someone got a answer. This is what I got so far:


Private Sub CommandButton1_Click()

On Error GoTo Error_Handler

'============================================================================================================================
' Dimensioninh variables
'============================================================================================================================

Dim Array1() As Variant
Dim Array2() As Variant
Dim i As Integer
Dim j As Integer
Dim a As Integer
Dim b As Integer
Dim varRange As String
Dim varFilname As String

Cells(1, 4) = Me.TextBox1.Value
Cells(1, 5) = Me.ComboBox1.Value


'============================================================================================================================
'Ressource Workbook
'============================================================================================================================

'Define array1 with Textbox1 value and Combobox1 value
varRange = "D1:E1"

'Choose range and store data
Range(varRange).Select
Array1 = Selection
varFilname = ActiveWorkbook.Name

'============================================================================================================================
'Database Workbook
'============================================================================================================================

'åbn foranalyseoversigt
Workbooks.Open Filename:="C:\Users\iMac\Desktop\Database.xlsx"
ActiveWorkbook.Sheets("Projects").Select

'Choose range and store data
i = SlutRaekke 'Function to find last row with data
varRange = "A2:C" & i
Range(varRange).Select
Array2 = Selection


Exit Sub

'============================================================================================================================
'Error handling
'============================================================================================================================

err_handler:

If Err.Number = 0 Then
Exit Sub
Else
MsgBox Err.Number & " " & Err.Description, vbMsgBoxSetForeground
Exit Sub
End If

End Sub

Viewing all articles
Browse latest Browse all 50199

Trending Articles