I have worked on the following code which copies 1 cell based on the criteria in column I. I knew how to set offset for -6 columns, the problem comes when I need cells Offset(0,-6) and Offset(0,-5) simultaneously as a range rather than offset. Can you please help? It’s this line: Range("I" & i).Offset(0, -6).Copy
where I need a range of cells from col C and D instead of simply offset (which gives me one cell).
Sub xxx()
Dim WB As Workbook
Dim ZXC As Worksheet
Dim INF As Long, RSP As Long
Set WB = Workbooks("test.xlsm")
Set ZXC = WB.Sheets("MMLPLC")
Set VBN = WB.Sheets("VBN")
ZXC.Activate
INF = Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To INF
If Range("I" & i).Value = "Further Information Needed" Then
Range("I" & i).Offset(0, -6).Copy
VBN.Range("C" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
End If
Next i
VBN.Activate
Application.CutCopyMode = False
End Sub
You can use the Resize method, which is very useful indeed
Range("I" & i).Offset(0, -6).resize(,2).copy
Tags: excelexcel, oop, sed