Okay, I need some backup help. I tried to work with xlDown. However, I need to repeat end(xldown).end(xldown).end(xldown).... to get to the end of my data because of the blanks. So, instead, I'm trying to make a count to the bottom row and use it to define my range to copy. But, I just can't seem to define the right syntax.
Sub codeX()
Dim wbTarget As Workbook, rg As Range, rgCopy As Range, wbthis As Workbook, ws As Worksheet, lastrow As Long
Set wbTarget = Workbooks("BPCdata.xlsm")
Set wbthis = Workbooks("Dashboard.xlsm")
wbthis.Worksheets(1).Cells.Clear
wbTarget.Activate
For Each rg In Worksheets(2).UsedRange
If rg.Value = "BIZTYPE: 123" Then
lastrow = Range("A" & Rows.Count).End(xlUp).Row
Set rngCopy = Range(rg.Offset(-3, 0), rg.Offset(-3, 0).lastrow.End(xlToRight))
rngCopy.Copy
wbthis.Worksheets("Donnees").Range("A1").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End If
Next rg
End Sub
My problems are from the two code in bold font.
Bookmarks