Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VB Code + Runtime error 91

I have been working on this vb code for a while now. The scenario is
that I am taking 1million+ records, filtering them through Access,
then exporting them to Excel. Once they are in excel I am appling
formulas and formats to specific columns. The sheets are spit out one
salesman at a time, formatted, closed, then the next one is spit out,
formatted and closed, and so on.

The very first sheet that comes out works great. However, it will not
continue. I end up with a Runtime Error 91 "Object variable or With
block variable not set". When I press debug "xl.Range(Selection,
Selection.End(xlUp).Offset(1, 0)).Select" is highlighted.

'Column GM%
xl.Range("A65536").End(xlUp).Offset(0, 11).Select
xl.Range(Selection, Selection.End(xlUp).Offset(1, 0)).Select
With xl.Selection.Interior
.Pattern = xlSolid
.ColorIndex = 33
End With
xl.Selection.NumberFormat = "0.0%"
xl.Range("A1").Select

If I take out that one line, everything is fine, except that I do not
get that column filled in with the color, but it does continue to the
next set of formats, stopping at the same spot in this section:

xl.Range("A65536").End(xlUp).Offset(0, 13).Select
xl.Range(Selection, Selection.End(xlUp).Offset(1, 0)).Select
With xl.Selection.Interior
.ColorIndex = 36
.Pattern = xlSolid
End With
xl.Selection.NumberFormat = "0.0%"
xl.Range("A1").Select

Does anyone have any ideas of what I am doing wrong here?

Thank you in advance.

Reply
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 code 1004 Karen Excel Worksheet Functions 1 May 13th 10 12:21 AM
VBA Code runtime error only after opening Locals window keeena Excel Programming 3 February 22nd 06 06:30 PM
After sharing workbook VB code stops working. Runtime Error 1004 Patrick LaFerriere Excel Programming 0 October 5th 05 04:01 PM
RunTime Error 424 in a USERFORM's code JimP Excel Programming 0 November 26th 04 05:27 AM
Repost with code - Runtime error '1004' muziq2[_20_] Excel Programming 5 July 17th 04 12:46 AM


All times are GMT +1. The time now is 12:09 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"