CaliburBlade138
New Member
- Joined
- Apr 18, 2021
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
Hey all,
I wrote some code to open up an excel file and get the number of used rows, but I am stumped on figuring out looking for a keyword *WH* in column J, if found, copy row and paste in new workbook, can anyone help finish this code?
I wrote some code to open up an excel file and get the number of used rows, but I am stumped on figuring out looking for a keyword *WH* in column J, if found, copy row and paste in new workbook, can anyone help finish this code?
VBA Code:
Sub Import_Data_And_Update()
Dim workbookA As Workbook, worksheetA As Worksheet
Dim workbookB As Workbook, worksheetB As Worksheet
Dim myFileName As String
Dim myLastR As Long
'Open the file dialog picker
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.Filters.Add "Excel Files", "*.xlsx; *.xlsm; *.xls; *.xlsb", 1
If .Show = False Then Exit Sub
myFileName = .SelectedItems.Item(1)
End With
'This workbook
Set workbookA = ThisWorkbook
Set worksheetA = workbookA.Sheets("Status")
Application.ScreenUpdating = False
'The workbook we are going to open
Set workbookB = Workbooks.Open(myFileName, True, True)
Set worksheetB = workbookB.Sheets("Backlog")
myLastR = worksheetB.Cells(Rows.Count, 1).End(xlUp).Row
'Do code here to copy from and to...
workbookB.Close False
End Sub