cvincent
Board Regular
- Joined
- Aug 28, 2011
- Messages
- 66
I am using Excel 2010, and when I download data into Excel, the Totals Row doesn't line up with the rest of the data. The totals row ends up in Column A, while the data starts in Column B. I am therefore trying to create a macro that will search Column A for the word "Range", then select that cell along with the adjoining cells to the right, cut and paste them one column to the right. This is the code I am using, but I am getting a runtime error 424 - Object Required error. I am not a pro in VBA, so assistance would be appreciated as to what I am doing wrong, or what I need. Thank you!
Sub AdjustTotalsRows()
'
' AdjustTotalsRows Macro
'
'
Dim rCell As Range
Dim rRng As Range
Set rng = Range("A:A")
For Each rCell In rRng
If rCell.Value = "TOTAL" Then
rCell.Select
ActiveCell.Range("A1:J1").Select
Selection.Cut
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(0, -1).Range("A1").Select
End If
Next rCell
End Sub
Sub AdjustTotalsRows()
'
' AdjustTotalsRows Macro
'
'
Dim rCell As Range
Dim rRng As Range
Set rng = Range("A:A")
For Each rCell In rRng
If rCell.Value = "TOTAL" Then
rCell.Select
ActiveCell.Range("A1:J1").Select
Selection.Cut
ActiveCell.Offset(0, 1).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(0, -1).Range("A1").Select
End If
Next rCell
End Sub