Excel_Blonde
New Member
- Joined
- Aug 8, 2018
- Messages
- 44
Hi all,
Can anyone help with the below code. I'm trying to look through all sheets across the range G4:K4 and move any data from the cells into I4. There is only 1 cell with data but it can be in any cell of the range.
It seems to work if I manually select a sheet and run the code, but doesn't automatically work across all sheets as intended. I'm sure it's something silly i'm missing but I just cant see it.
Sub Movepartcodetrial()
Dim ws As Worksheet
For Each ws In Worksheets
If Range("G4") <> "" Then
Range("G4").Cut Range("I4")
ElseIf Range("H4") <> "" Then
Range("H4").Cut Range("I4")
ElseIf Range("J4") <> "" Then
Range("J4").Cut Range("I4")
ElseIf Range("K4") <> "" Then
Range("K4").Cut Range("I4")
End If
Exit For
Next ws
End Sub
Any help would be appreciated.
Can anyone help with the below code. I'm trying to look through all sheets across the range G4:K4 and move any data from the cells into I4. There is only 1 cell with data but it can be in any cell of the range.
It seems to work if I manually select a sheet and run the code, but doesn't automatically work across all sheets as intended. I'm sure it's something silly i'm missing but I just cant see it.
Sub Movepartcodetrial()
Dim ws As Worksheet
For Each ws In Worksheets
If Range("G4") <> "" Then
Range("G4").Cut Range("I4")
ElseIf Range("H4") <> "" Then
Range("H4").Cut Range("I4")
ElseIf Range("J4") <> "" Then
Range("J4").Cut Range("I4")
ElseIf Range("K4") <> "" Then
Range("K4").Cut Range("I4")
End If
Exit For
Next ws
End Sub
Any help would be appreciated.