LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Object Variable or With Block variable not set?

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Runtime Error '91' Object variable or With block variable not set Alec Coliver Excel Discussion (Misc queries) 2 October 24th 09 02:29 PM
Object Variable Not Set Error on Selection object Jean Excel Worksheet Functions 3 July 24th 06 06:45 PM
Run time error '91' object variable-explain in plain english?? KristyBT Excel Discussion (Misc queries) 2 April 27th 06 07:53 PM
object variable or with block variable not set Diego Excel Discussion (Misc queries) 1 August 9th 05 02:46 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM


All times are GMT +1. The time now is 05:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"