+ Reply to Thread
Results 1 to 7 of 7

autosizing

  1. #1
    Registered User
    Join Date
    07-27-2010
    Location
    Canberra, Australia
    MS-Off Ver
    Excel 2003
    Posts
    8

    autosizing

    I have used 2 macros in order to automatically resize the row height in merged cells when using wordwrap. The first code enables the resizing, the second to automatically run the macro when the sheet changes. The problem I have having is that the resizing only occurs if I re-click on the cell after I have entered the data. Can someone tell me what I am doing wrong? Here is the code I am using:

    To resize rows (located in the Module)
    Please Login or Register  to view this content.
    To automatically run the macro when a change is made within the sheet (located in the worksheet Object)

    Please Login or Register  to view this content.
    Thanks

    Tania
    Last edited by romperstomper; 07-27-2010 at 03:20 AM. Reason: Added code tags

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,317

    Re: autosizing

    Hi and welcome to the forum.

    Please can you enclose all code in code tags when posting in future? (I have added them for you on this occasion)

    Your problem is that your code uses the selectionchange event which occurs when you select another cell, not when you alter a cell. Hence the active cell to which your code refers is not the one you just changed. You need to use the Change event instead.
    Last edited by romperstomper; 07-27-2010 at 03:27 AM.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: autosizing

    Hi windaroo,
    The first trick is dont merge cells but, if you have then
    In the same row where the cells are merged, and a column out of site, size a cell to the same width as the meged cells and enter formula to = the merged cell . Format the cell for text wrap. now the cells will auto resize to match the merged cells.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  4. #4
    Registered User
    Join Date
    07-27-2010
    Location
    Canberra, Australia
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: autosizing

    Okay, so I know my resizing code works, but I still can't get my macro to auto run. I have tried the Worksheet_Change(ByVal Target As Range) but now my macro won't autorun at all.

    The sheet is being used to collect annual performance assessment data, so it will be filled out my many other users. I simply want the macro to run, when users enter commentary. Unfortunately I can't get away with not having merged cells. I also tried adding in another column but this didn't work either.

    And apologies for not following the correct posting format, thanks for letting me know. I will be sure use the tags in the future.


  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,317

    Re: autosizing

    Just make sure you haven't ended up with events disabled. In the VBE, press Ctrl+G to open the Immediate Window, type:
    Please Login or Register  to view this content.
    in the window and press enter. Then see if the code runs.

  6. #6
    Registered User
    Join Date
    07-27-2010
    Location
    Canberra, Australia
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: autosizing

    Quote Originally Posted by romperstomper View Post
    Just make sure you haven't ended up with events disabled. In the VBE, press Ctrl+G to open the Immediate Window, type:
    Please Login or Register  to view this content.
    in the window and press enter. Then see if the code runs.
    Thanks for your help, nothing happened though. I have tried a number of different ways to code it and still can't get it work on the Worksheet_Change event.

    Please keep helping me!

  7. #7
    Registered User
    Join Date
    07-27-2010
    Location
    Canberra, Australia
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: autosizing

    Thanks for your help. I managed to find another set of code that has solved all my problems. It is probably not as clean as I would like but it works.

+ 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