Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Runtime Error '91' Object variable or With block variable not set | Excel Discussion (Misc queries) | |||
Object Variable Not Set Error on Selection object | Excel Worksheet Functions | |||
Run time error '91' object variable-explain in plain english?? | Excel Discussion (Misc queries) | |||
object variable or with block variable not set | Excel Discussion (Misc queries) | |||
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? | Excel Worksheet Functions |