+ Reply to Thread
Results 1 to 6 of 6

Error 91 - Sometimes happens, sometimes it doesnt.

  1. #1
    BerkshireGuy
    Guest

    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. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    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

  3. #3
    STEVE BELL
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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
    >




  4. #4
    BerkshireGuy
    Guest

    Re: Error 91 - Sometimes happens, sometimes it doesnt.

    Steve,

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

    Thanks

    Brian


  5. #5
    STEVE BELL
    Guest

    Re: Error 91 - Sometimes happens, sometimes it doesnt.

    My bad....

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

    --
    steveB

    Remove "AYN" from email to respond
    "BerkshireGuy" <[email protected]> wrote in message
    news:[email protected]...
    > Steve,
    >
    > Ok, I modified as suggested now I am getting Method Worksheet of Global
    > failed.
    >
    > Thanks
    >
    > Brian
    >




  6. #6
    Tom Ogilvy
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1