Announcement

Collapse
No announcement yet.

Unconfigured Ad Widget

Collapse

Unable to Set the ColumnWidth Property of the Range Class. Merged Cell

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unable to Set the ColumnWidth Property of the Range Class. Merged Cell

    When a user selects a merged cell within a named range the column width is reset to accommodate the longest string in a separate list. In order to do this the code first loops through the list to get the largest string which it places in a variable intLargestString. The code fails on the second line below with run-time error '1004' unable to set the ColumnWidth property of the Range class

    Code:
    Application.Goto Target
    Selection.ColumnWidth = intLargestString
    Any ideas appreciated
    Auto Merged Post;

    Solved - the worksheet was protected
    Last edited by cymro; August 22nd, 2007, 06:39. Reason: Auto Merged Doublepost

  • #2
    Re: Set Column Width Of Merged Cell

    "Target" suggest that you are using an event macro. If your code is changing the active cell, then the event macro may be firing multiple times -- with a different "Target." Have you tried inserting
    Code:
    MsgBox Target.address
    immediately before the problem line to see what it returns?

    But as an aside, I would offer that it is good practice to avoid using merged cells. THey can cause havoc with VBA code. Use Format > Center Across Selection or other formatting tricks to accomplish teh look of a merged cell without actually using one.
    Best Regards,
    Tom
    ---------------------------
    Please help Oz share knowledge among all users by posting your questions in a public forum rather than using a Private Message.

    Comment

    Trending

    Collapse

    There are no results that meet this criteria.

    Working...
    X