+ Reply to Thread
Results 1 to 7 of 7

Excel 2007 : Auto-adjust row height on VLOOKUP?

  1. #1
    Registered User
    Join Date
    08-15-2010
    Location
    Norfolk, England
    MS-Off Ver
    Excel 2007
    Posts
    3

    Auto-adjust row height on VLOOKUP?

    I have a sheet of data including a column into which I am entering text. The cells in this column are formatted as 'general' with text autowrap and the height increases with additional lines of text exactly as it should.

    My problem is that I have another sheet in the same workbook which uses VLOOKUP to pull information through from two other sheets including the one mentioned above and display the information as a form but the cell containing the text, although formatted the same, does not grow with extra lines of text but remains at its original height.

    Is it possible to have the 'form' cell grow as necessary with extra text?
    Last edited by cornishdave; 08-16-2010 at 09:44 AM.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Auto-adjust row height on VLOOKUP?

    Hello cornishdave,

    if the cell with the Vlookup formula is a merged cell, then I'm afraid you're out of luck. Merged cells do not auto-adjust the row height at all. You'll need to manually adjust it.

    If it's not a merged cell, then you can run a macro when the sheet is calculated to recalculate the row heights. A formula does not trigger a recalculation of row height when the result of the formula changes. But if the sheet is calculated, the row height can be checked.

    Put this code into the sheet module and enable macros.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-15-2010
    Location
    Norfolk, England
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Auto-adjust row height on VLOOKUP?

    [I]
    Quote Originally Posted by teylyn View Post
    Hello cornishdave,

    Put this code into the sheet module and enable macros.

    Please Login or Register  to view this content.


    Hi Teylyn and thanks for your reply.

    Unfortunately, Visual Basic is a bit outside my experience so I'm struggling here. I don't have any merged cells on any of the sheets in the workbook. I have opened VB Module and pasted the code. I've also been into Macro Security and enabled Macros and saved the file as macro-enabled but it still doesn't work.

    I've attached a copy of the file (with images removed to reduce file size) in the hope that you might see what I'm missing.

    Thanks, cornishdave
    Attached Files Attached Files

  4. #4
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Auto-adjust row height on VLOOKUP?

    Hello cornishdave,

    Unfortunately, Visual Basic is a bit outside my experience so I'm struggling here.
    No worries. None of us were born with VBA knowledge. You were actually very close to a working solution.

    You put the code I posted into a standard module. But the code I posted monitors a sheet for an event (the sheet being recalculated, because cell contents have changed). So this code is triggered by a Sheet event (if the sheet calculates, the code runs), but for this to work, you need to put it in the sheet module.

    Right-click the Invoice sheet tab, click View Code and paste the code into the code window. Close the VBE and then test.

    See attached for a working solution.

    cheers
    Attached Files Attached Files
    Last edited by teylyn; 08-16-2010 at 08:58 AM. Reason: dypos

  5. #5
    Registered User
    Join Date
    08-15-2010
    Location
    Norfolk, England
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Auto-adjust row height on VLOOKUP?

    Fantastic! Sorted - thanks again, Teylyn.

  6. #6
    Registered User
    Join Date
    07-03-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    1

    Exclamation Re: Auto-adjust row height on VLOOKUP?

    Hi,

    The code pasted above is working for the whole sheet even for the hidden rows and the hidden rows are getting unhidden.Could there be any other way to not display the hidden rows and apply the Auto-adjust row height on VLOOKUP for only selected rows? Please reply...

  7. #7
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: Auto-adjust row height on VLOOKUP?

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.
    HTH
    Regards, Jeff

+ 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