justme1122
New Member
- Joined
- Mar 6, 2011
- Messages
- 47
Hi guys
Sorry, im rather new to VBA and having a little bit of a problem with this error:
Object variable not set (Error 91)
From my understanding something s missing from the top few lines but im unsure how to fix it.
There line that debug highllights is in red.
Thanks so much for any help
scott
Sorry, im rather new to VBA and having a little bit of a problem with this error:
Object variable not set (Error 91)
From my understanding something s missing from the top few lines but im unsure how to fix it.
PHP:
Sub Shift_Data()
Dim Found As Range, col As Long, Lastrow As Long
Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In Worksheets
col = 1
Set Found = ws.Columns(col).Find("SubTotal", , xlValues, xlWhole, xlByRows, xlNext, False)
If Not Found Is Nothing Then
Lastrow = ws.Range("k" & Rows.Count).End(xlUp).Row
If Found.Row <> Lastrow Then
Do
ws.Range(Found.Offset(1), ws.Cells(Lastrow, col)).Insert Shift:=xlToRight
col = col + 1
Set Found = ws.Columns(col).Find("SubTotal")
Loop Until Found.Row = Lastrow
End If
End If
Next ws
Application.ScreenUpdating = True
End Sub
There line that debug highllights is in red.
Thanks so much for any help
scott