True, you put it in Range("E250").End(xlup).Offset(5,-2)
but when you run the search, you only have one cell selected - unlike in
Excel itself, the find only looks in that cell.
Sub AATester2()
Range("C2").Select
Selection.Find(What:="grand total", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False).Activate
End Sub
fails because the target isn't in C2
but
Sub AATester2()
Range("C:C").Select
Selection.Find(What:="grand total", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False).Activate
End Sub
Works.
Grand Total is in C24 in my test.
--
Regards,
Tom Ogilvy
"Chris M." wrote in message
...
I get the above error message trying to runa recorded
macro. I'm too new to VB to understand exactly what the
issue is. Perhaps someone else can help. Here's the
current code I'm using:
Private Sub Findtotal()
Dim rng As Range
Dim Cell As Range, LastCell As String
Application.ScreenUpdating = False
Columns("A:A").Select
Set rng = Selection.Find(What:="Fees",
After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng Is Nothing Then
rng.Select
Range(ActiveCell.Offset(1, 0), ActiveCell.Offset
(1, 0).End(xlDown)).Select
For Each Cell In Selection
If Not IsEmpty(Cell) Then Cell = Cell & " FEES"
Next
End If
For Each Cell In Range("F3:F200")
If WorksheetFunction.CountA(Cell.EntireRow) 0 Then _
Cell.FormulaR1C1 = "=IF(RIGHT(RC1,4)
=""FEES"",RC5,0)"
Next
For Each Cell In Range("G3:G200")
If WorksheetFunction.CountA(Cell.EntireRow) 0 Then _
Cell.FormulaR1C1 = "=IF(RC[-3]=""TOTALS"",RC[-
2],0)"
Next
Range("E250").End(xlUp).Offset(3, -2) = "Subtotal Less
Fees"
Range("E250").End(xlUp).Offset(4, -2) = "Total Fees"
Range("E250").End(xlUp).Offset(5, -2) = " GRAND TOTAL"
Range("E250").End(xlUp).Offset(3, 0).Select
ActiveCell.FormulaR1C1 = "=SUM(C[2])-SUM(C[1])"
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=SUM(C[1])"
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=SUM(C[2])"
ActiveCell.Interior.ColorIndex = 15
With ActiveCell.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With ActiveCell.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
ActiveCell.CurrentRegion.Select
With Range(Selection, Selection.End(xlToLeft))
.Font.Bold = True
.HorizontalAlignment = xlLeft
End With
'''
'''
Columns("E:E").NumberFormat = "$#,##0.00_);($#,##0.00)"
Columns("E:E").HorizontalAlignment = xlGeneral
Columns("F:G").EntireColumn.Hidden = True
Range("A1").EntireRow.Insert
Range("A1") = "CENTEX HOMES CORPORATION"
With Range("A1").Font
.Name = "Century Gothic"
.Bold = True
.Size = 12
.ColorIndex = 3
End With
'''
ActiveCell.Cells.Select
ActiveCell.Activate
Selection.Find(What:="grand total", After:=ActiveCell,
LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False).Activate
It's the last line that gives the error, but I'm positive
that the 'Grand Total' value exists, since it is placed
into the spreadsheet in earlier code. Any help is greatly
appreciated.