Help with using a Macro Loop
The following macro copies all of row 1 in Sheet1 to row 1 of Sheet2
------------------------------------------------------------------------------------------------
Sub CopyRow()
Dim wsSource As Worksheet
Dim wsTarget As Worksheet
Dim varVal(255) As Variant
Dim i As Integer
Set wsSource = ThisWorkbook.Sheets(1)
Set wsTarget = ThisWorkbook.Sheets(2)
With wsSource.Range("A1")
For i = 0 To 255
varVal(i) = .Offset(, i).Value
Next i
End With
With wsTarget.Range("A1")
For i = 0 To 255
.Offset(, i).Value = varVal(i)
Next i
End With
Set wsSource = Nothing
Set wsTarget = Nothing
End Sub
------------------------------------------------------------------------------------------------
--
Kevin Backmann
"Mark Costello" wrote:
Hello,
could someone help me with using a macro?
I need to use a macro to work along the columns of a spreadsheet (i.e.
select cell A1, copy, paste in another spreadsheet's A1, then select cell B1
and if not blank, copy and paste in the other spreadsheet's B1 and so on).
I will be using nearly all the columns in the spreadsheet so it's not
feasable to just type in the cells in the macro, hence the need for a loop.
Any help would be appreciated!!
Thanks
|