Hi ammartino44,
Here's my code commented:
Option Explicit 'Forces variable declaration at run time. Without it, any undeclared variables will be assigned as variants - the most expensive (in terms of memory) type of variable.
Sub Macro1()
'Declare constant variable. As these types of variables are usually static they provide a good starting reference
Const lngStartRow As Long = 3 'Starting row number for the data. Change to suit.
'Declare dynamic variables
Dim lngLastRow As Long, _
lngMyRow As Long
'Finds the last row from columns B and C
lngLastRow = Range("B:C").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
'Turn screen updating off
Application.ScreenUpdating = False
'Loop through each row in the defined number of rows
For lngMyRow = lngStartRow To lngLastRow
'If Col. B of the 'lngMyRow' row equals zero and Col. C is greater than zero, then...
If Val(Range("B" & lngMyRow)) = 0 And Val(Range("C" & lngMyRow)) > 0 Then
'...make the values across Col's B to J the same as Col's C to K, and...
Range("B" & lngMyRow & ":J" & lngMyRow).Value = Range("C" & lngMyRow & ":K" & lngMyRow).Value
'...clear the contents in Col. K, and...
Range("K" & lngMyRow).ClearContents
'...make the values across Col's M to U the same as Col's N to V, and...
Range("M" & lngMyRow & ":U" & lngMyRow).Value = Range("N" & lngMyRow & ":V" & lngMyRow).Value
'...clear the contents in Col. V, and...
Range("V" & lngMyRow).ClearContents
'...make the values across Col's X to AF the same as Col's Y to AG, and...
Range("X" & lngMyRow & ":AF" & lngMyRow).Value = Range("Y" & lngMyRow & ":AG" & lngMyRow).Value
'...clear the contents in Col. AG, and...
Range("AG" & lngMyRow).ClearContents
'...make the values across Col's AI to AQ the same as Col's AJ to AR, and...
Range("AI" & lngMyRow & ":AQ" & lngMyRow).Value = Range("AJ" & lngMyRow & ":AR" & lngMyRow).Value
'...clear the contents in Col. AR
Range("AR" & lngMyRow).ClearContents
End If
Next lngMyRow
'Turn screen updating back on
Application.ScreenUpdating = True
End Sub
HTH
Robert
Bookmarks