Hi there,
I am running into an issue when trying to run the following:
*If values in column A are greater than zero, paste values in column C
*If values in column A are zero, copy values from column B (in same row) and paste in column C
Columns are of variable lenght and values begin from A2 onwards.
So far, I've tried the first step only without success using the below. Ideally I would not like to choose "range A:A)" but something that will run trough cells with data only.
Can somebody please point me in the right direction?
Thanks!!!
"
"
I am running into an issue when trying to run the following:
*If values in column A are greater than zero, paste values in column C
*If values in column A are zero, copy values from column B (in same row) and paste in column C
Columns are of variable lenght and values begin from A2 onwards.
So far, I've tried the first step only without success using the below. Ideally I would not like to choose "range A:A)" but something that will run trough cells with data only.
Can somebody please point me in the right direction?
Thanks!!!
"
Code:
Sub CopyValues()
Dim x As Range
For Each x In Range("A:A")
If x.Value > 0 Then
x.Select
Selection. Copy
Columns("C:2").Select
ActiveSheet.Paste
End If
Next i
Dim z As Range
For Each z In Range("A:A")
If z.Value = 0 Then
Columns("B:B").Select
Selection. Copy
Columns("C:2").Select
ActiveSheet.Paste
End If
Next z
End Sub
Last edited by a moderator: