How do I insert cells in a macro?
Sorry for the delay in replying, I have been on vacation. This didn't fix
it, however. It didn't do anything. On my spreadsheet, in column A, the
words, "GRAND TOTAL:" are in all caps with the ":" at the end. I changed the
words in the " " to read in all caps and added the ":". Also, at the end,
the shift:-x1ToRight seems to draw the error, "Compile Error, Expected
Expression." If i put it at the end of the line above, I get no error, but
nothing happens either.
Am I not doing this right? I even changed the name of the sheet to Sheet3.
"JMB" wrote:
Does this help any?
Sub test()
Const lngRowsToInsert As Long = 7
Const strCriteria As String = "Grand Total:"
Dim rngGrandTotal As Range
With Sheets("Sheet3").Range("A:A")
Set rngGrandTotal = .Find( _
what:=strCriteria, _
after:=.Cells(1), _
LookIn:=xlValues, _
lookat:=xlWhole, _
searchorder:=xlByRows, _
searchdirection:=xlNext, _
MatchCase:=False, _
matchbyte:=False)
End With
If Not rngGrandTotal Is Nothing Then
rngGrandTotal.Cells(1).Resize(lngRowsToInsert, 1).Columns.Insert
shift:=xlToRight
Else
'Grand Total was not found
End If
End Sub
"ruby02monday" wrote:
I have a worksheet with 6 columns 300+ rows. I have a macro that preforms a
a filter, delete rows based on blanks, turn off filter and save as values.
Now I need to find "GRAND TOTAL:". in Column A. This is variable. Once
found, insert 7 cells and shift right.
It has got to be staring me in the face, but I can't see it anymore. Please
help!!
|