I am trying to automate a copy & paste job basically. I want to bring over data from one document into another. I want to find the data based on the content in a cell which is not always in the same place and I want to select values below that cell up to the next blank row.
For example: Select all cells in a range below the cell that says "CURRENT MONTH" until the next row that is blank.
This is what I have so far:
Sub getCurrentMonth()
'get the current month data
Windows("File1.xlsm").Activate
Sheets("Sheet1").Select
celltxt = ActiveSheet.Range("B1:B1000").Text
If InStr(1, celltxt, "CURRENT MONTH") Then
N = Cells(7, 2).End(xlDown).Select
Range("B7:AD" & N).Select
Selection.Copy
Windows("Automation.xlsm").Activate
Sheets("Sheet1").Select
Range("A2").Select
ActiveSheet.Cells(rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial
Else
MsgBox ("No data for Current Month Found")
End If
End Sub
Set rngCell = ActiveSheet.Range("B:B").Find(What:="CURRENT MONTH", LookAt:=xlWhole).Offset(1,0)to retrieve the cell (it looks in the entire column for a cell whose text is exactly equal to "CURRENT MONTH"). Then useRange(rngCell.Address & ":" & rngCell.Address.End(xlDown).Address).Copyto copy the range.