Hi experts
I need combining two code instead of repeat the code again for different ranges
so the code import data from Prompt user to browse & Select file from folder . I have two ranges for two files when select from folder
first
second
as you see there is different in ranges.
I have some notices if it's possible just select the folder and pull data from files without select files and when pull data should skip blank cells in ranges or make search for tha lastrow instead of specify the range every time .
I hope finding easy way to do that .
I need combining two code instead of repeat the code again for different ranges
so the code import data from Prompt user to browse & Select file from folder . I have two ranges for two files when select from folder
first
VBA Code:
Sub ge_tdata()
Dim ar As Variant, lRw As Long
lRw = ThisWorkbook.Sheets("sheet1").Cells(Rows.Count, 2).End(xlUp).Row
With Application.FileDialog(msoFileDialogFilePicker)
If .Show Then
With GetObject(.SelectedItems(1))
ar = .Sheets("rp").Range("g2:i100").Value
ThisWorkbook.Sheets("sheet1").Cells(lRw + 1, 2).Resize(UBound(ar), UBound(ar, 2)) = ar
.Close 0
End If
End With
End If
End With
End Sub
second
VBA Code:
Sub ge_tdata()
Dim ar As Variant, lRw As Long
lRw = ThisWorkbook.Sheets("sheet1").Cells(Rows.Count, 2).End(xlUp).Row
With Application.FileDialog(msoFileDialogFilePicker)
If .Show Then
With GetObject(.SelectedItems(1))
ar = .Sheets("rp").Range("A2:E100").Value
ThisWorkbook.Sheets("sheet1").Cells(lRw + 1, 2).Resize(UBound(ar), UBound(ar, 2)) = ar
.Close 0
End If
End With
End If
End With
End Sub
I have some notices if it's possible just select the folder and pull data from files without select files and when pull data should skip blank cells in ranges or make search for tha lastrow instead of specify the range every time .
I hope finding easy way to do that .