Belair58
Board Regular
- Joined
- Mar 31, 2005
- Messages
- 95
Hello,
I'm attempting to find a word, highlight that cell and all the cells to the right of it. Cut that range and then paste it over 3 cells to the right.
Once I get the cut and paste working, I'll need to work on the loop to look at the entire column.
I think I'm close but I'm getting a run-time error 91 "Object Variable or With block variable not set" with the code below.
Any help would be appreciated.
I'm attempting to find a word, highlight that cell and all the cells to the right of it. Cut that range and then paste it over 3 cells to the right.
Once I get the cut and paste working, I'll need to work on the loop to look at the entire column.
I think I'm close but I'm getting a run-time error 91 "Object Variable or With block variable not set" with the code below.
Any help would be appreciated.
Code:
Sub MoveTotals()
'
Dim rngFound As Range
Dim rngCapture As Range
With Worksheets(1).Range("D:D")
Set rngFound = .Find(What:="Totals:", LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
If Not (rngFound Is Nothing) Then
rngCapture = rngFound.End(xlToRight).Select
rngCapture.Cut
rngFound.Offset(0, 3).Value = rngCapture
Else
MsgBox "The word 'Totals:' was not found in column D"
End If
End With
End Sub