Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Error 91 - Sometimes happens, sometimes it doesnt.

Ok, sounds like an Almond Joy commerical.

Anyways, I have the following code and sometimes I get an error 91 and
sometimes I dont.

Any ideas?

objWkb.Worksheets("Sorted Rankings").Range("A1:B1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = True
End With

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Error 91 - Sometimes happens, sometimes it doesnt.

You can make this easier:
=======================================
With Worksheets("Sorted Rankings").Range("A1:B1")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = True
End With
===========================
And you may not need the lines = False

I'm not sure what error91 is. But your code will fail if the worksheet is
not the active sheet.
The above code doesn't care. It also works faster by not selecting
anything.
--
steveB

Remove "AYN" from email to respond
"BerkshireGuy" wrote in message
oups.com...
Ok, sounds like an Almond Joy commerical.

Anyways, I have the following code and sometimes I get an error 91 and
sometimes I dont.

Any ideas?

objWkb.Worksheets("Sorted Rankings").Range("A1:B1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = True
End With



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Error 91 - Sometimes happens, sometimes it doesnt.

Steve,

Ok, I modified as suggested now I am getting Method Worksheet of Global
failed.

Thanks

Brian

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error 91 - Sometimes happens, sometimes it doesnt.


Hello BerkshireGuy,

Error 91 - "Object variable or With Block variable not set." The With
Block looks fine. I suspect somewherelse in your code objWkb is not
being set.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=379162

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Error 91 - Sometimes happens, sometimes it doesnt.

My bad....

Change Worksheets(.....) to Sheets(....)

--
steveB

Remove "AYN" from email to respond
"BerkshireGuy" wrote in message
ups.com...
Steve,

Ok, I modified as suggested now I am getting Method Worksheet of Global
failed.

Thanks

Brian





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Error 91 - Sometimes happens, sometimes it doesnt.

With objWkb.Worksheets("Sorted Rankings").Range("A1:B1")
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = True
End With

--
Regards,
Tom Ogilvy

"BerkshireGuy" wrote in message
oups.com...
Ok, sounds like an Almond Joy commerical.

Anyways, I have the following code and sometimes I get an error 91 and
sometimes I dont.

Any ideas?

objWkb.Worksheets("Sorted Rankings").Range("A1:B1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = True
End With



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
Why doesnt this work? MurrayBarn Excel Worksheet Functions 2 November 19th 09 04:21 PM
Why doesnt this work steve New Users to Excel 1 March 3rd 08 04:52 PM
I want to correct a #div/0! error but the IF function doesnt work Traceyb Excel Worksheet Functions 1 July 21st 05 03:47 PM
TAB Key doesnt work. Murat D. Hekimošlu Excel Programming 1 January 25th 05 10:48 AM


All times are GMT +1. The time now is 02:44 AM.

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"