Hi,
I am needing to use a variant to find a range of where my keyword is found on multiple rows so I can copy data to another source but when I run the code I have a run time error 1004. The code worked fine when I had defined integers with set values.
I am not an expert in VBA, merely manipulating code I've found on forums to make it relevant for my purposes.
Thanks,
Jas
I am needing to use a variant to find a range of where my keyword is found on multiple rows so I can copy data to another source but when I run the code I have a run time error 1004. The code worked fine when I had defined integers with set values.
I am not an expert in VBA, merely manipulating code I've found on forums to make it relevant for my purposes.
VBA Code:
Sub Macro1()
Worksheets("Receivables").Activate 'worksheet name
Dim FSearchRow As Variant 'first row of keyword search
Dim LSearchRow As Variant 'last row of keyword search
FSearchRow = "=MATCH(A2,A:A, 0)" 'A2 is for test purposes as I will ref another worksheet for unique ids
LSearchRow = "=(MATCH(A2,A:A,0)+(COUNTIF(A:A,A2))-1)"
Dim rng As Range
Set rng = Range("B" & CStr(FSearchRow) & ":" & "B" & CStr(LSearchRow)) 'range will change on variable first and last rows where this part is getting errors
rng.Copy Range("L1:L30") 'test purposes as I will copy to another worksheet
End Sub
Thanks,
Jas