![]() |
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 |
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 |
Error 91 - Sometimes happens, sometimes it doesnt.
Steve,
Ok, I modified as suggested now I am getting Method Worksheet of Global failed. Thanks Brian |
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 |
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 |
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 |
All times are GMT +1. The time now is 07:03 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com