hello im trying to make a small system where i can import many files to 1 file with userforms ect
1. Source file
i want to import all data from source file to destination file
source file has data in Column A:J(on sheet1) and A:L(on sheet2)
and i want this imported to destination file (sheet4)D:N and D:P(sheet5)
2. Imported data has to add to First empty row
3. i need to add some values that are selected on the userform (ID) Column A (companyname) on Column B (clientname) On Column C that where selected on the userform
i cant find any code to work with
thanks in advance
1. Source file
i want to import all data from source file to destination file
source file has data in Column A:J(on sheet1) and A:L(on sheet2)
and i want this imported to destination file (sheet4)D:N and D:P(sheet5)
2. Imported data has to add to First empty row
3. i need to add some values that are selected on the userform (ID) Column A (companyname) on Column B (clientname) On Column C that where selected on the userform
Code:
Private Sub userform_activate()
Dim cell As Range
With Worksheets("Database Bedrijf")
For Each cell In .Range("B2:B1000" & .cells(Rows.Count, 3).End(xlUp).Row)
If Not IsEmpty(cell) Then Bedrijf.AddItem cell.Value
Next cell
End With
'''This declares the data type of the variable "LstRw'
Dim LstRw1 As Long
Dim LstRw2
'''This defines what the variable "LstRw' is to refer to. _
(The row number of the last used cell in column A.)
LstRw1 = Blad8.cells(Rows.Count, "A").End(xlUp).Row
LstRw2 = Blad9.cells(Rows.Count, "A").End(xlUp).Row
'''This tells the textbox named ID to equal the value of the last used cell in Col.A after adding 1 to it.
ID1.Caption = Blad8.cells(LstRw1, "A").Value + 1
ID2.Caption = Blad9.cells(LstRw2, "A").Value + 1
End Sub
Private Sub Bedrijf_Change()
Dim RowMax As Integer
Dim wsh As Worksheet
Dim countExit As Integer
Dim CellCombo2 As String
Dim i As Integer
Set wsh = ThisWorkbook.Sheets("Database Klant")
RowMax = wsh.cells(Rows.Count, "B").End(xlUp).Row
'find last row of sheet in column A
Klant.Clear
'clear all value of comboBox2
With Klant
For i = 2 To RowMax
If wsh.cells(i, "B").Value = Bedrijf.Text Then
'Just show value of mapping with column A
.AddItem wsh.cells(i, "C").Value
.List(.ListCount - 1, 3) = wsh.cells(i, "D").Value
Else
End If
Next i
End With
End Sub
Private Sub CommandButton1_Click()
Call Import1
End Sub
Sub Import1()
Const TARGET_COL As String = "C" 'adjust letter for your column
Dim ws As Worksheet
Dim selectedFile As Variant
Dim cell As Range
'Find the next blank cell in target column
Set ws = ThisWorkbook.Worksheets("Sheet4")
Set cell = ws.cells(ws.Rows.Count, TARGET_COL).End(xlUp).Offset(1)
'Open the file dialog window
selectedFile = Application.GetOpenFilename("Text Files (*.xlsx), *.xlsx")
'Check if user hit cancel
If selectedFile = False Then Exit Sub
'Write the file name
cell.Value = selectedFile
End Sub
i cant find any code to work with
thanks in advance
Last edited: