Resize a row but copy but skip columns I don't want to copy
Hi Howard,
Am Fri, 30 Aug 2013 00:22:14 -0700 (PDT) schrieb Howard:
With the resize in this segment of code, it copies col A and B. On that same row I want to also copy col D and F.
So the resize would be c.Offset(0, -1).Resize(1, col's A, B, D, F).Copy
Is that possible in a routine resize?
resize works only with adjacent cells.
Try:
lRow = Cells(Rows.Count, 2).End(xlUp).Row
Set bRng = Range("B14:B" & lRow)
myArr = Array(1, 2, 4, 6)
For Each c In bRng
If c.Value < "" Then
lRow = Worksheets("Invoice Data"). _
Cells(Rows.Count, 3).End(xlUp).Row + 1
For i = LBound(myArr) To UBound(myArr)
Worksheets("Invoice Data").Cells(lRow, i + 3) _
= Cells(c.Row, myArr(i))
Next
End If
Next
Or with another For-Next statement:
lRow = Cells(Rows.Count, 2).End(xlUp).Row
Set bRng = Range("B14:B" & lRow)
For Each c In bRng
If c.Value < "" Then
lRow = Worksheets("Invoice Data"). _
Cells(Rows.Count, 3).End(xlUp).Row + 1
j = 5
c.Offset(0, -1).Resize(, 2).Copy _
Worksheets("Invoice Data").Range("C" & lRow)
For i = 4 To 6 Step 2
Cells(c.Row, i).Copy _
Worksheets("Invoice Data").Cells(lRow, j)
j = j + 1
Next
End If
Next
Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
|