I am a VBA beginner and I have copied and modified some existing code to suit my purposes, but I'm doing something simple wrong.
What I am trying to achieve is the following: - Loop through Row 1, from Column A to Column Z - If cell of row 1 is greater than 0, Copy Row 1 cell, and paste it in Row 2.
Below is the code I'm using.
Sub CopyData()
Dim LastRow As Long, ws As Worksheet
Set ws = Sheets("Sheet3")
For x = A To Z
If ws.Range(x & "1").Value <> 0 Then
ws.Range(x & "1").Copy
ws.Range(x & "2").PasteSpecial xlPasteValues
End If
Next x
End Sub
What I am trying to achieve is the following: - Loop through Row 1, from Column A to Column Z - If cell of row 1 is greater than 0, Copy Row 1 cell, and paste it in Row 2.
Below is the code I'm using.
Sub CopyData()
Dim LastRow As Long, ws As Worksheet
Set ws = Sheets("Sheet3")
For x = A To Z
If ws.Range(x & "1").Value <> 0 Then
ws.Range(x & "1").Copy
ws.Range(x & "2").PasteSpecial xlPasteValues
End If
Next x
End Sub