+ Reply to Thread
Results 1 to 9 of 9

Automatically expanding cells to accomodate VLOOKUP results

  1. #1
    Registered User
    Join Date
    11-22-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    7

    Automatically expanding cells to accomodate VLOOKUP results

    Excel 2010
    I am using VLOOKUP to bring sentences into cells in the left-most column of Sheet 1, based on what product name is entered by a user. These sentences are on sheet 2 in an array, and range in length from a few words to a few sentences per cell. I use Wrap Text to make sure the sentences don't stretch out across the page on Sheet 1, and I have used "Auto-fit Row Height" to make sure the cell accomodates the sentence correctly. However, when I change the product name, VLOOKUP brings in a new set of sentences (they vary according to the product entered), and the cell heights don't change to accomodate the new sentences. Can anyone tell me if it is possible to get the cells to dynamically change to suit the sentences each time a new product is entered by the user? Please feel free to ask me any questions.

  2. #2
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Automatically expanding cells to accomodate VLOOKUP results

    Hi r011in,

    I believe the auto fit will work if the data is entered manually (i.e., with a press of Enter).. if data is coming via formula, it wont change..
    Press F2 on the formula and press enter.. let me what happens.. thanks.

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  3. #3
    Registered User
    Join Date
    11-22-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Automatically expanding cells to accomodate VLOOKUP results

    Hi DILIPandey,
    Thanks for your reply. If I enter the data manually, the autofit works, but using the formula it doesn't. F2 has no effect unfortunately. Is there any way around this?

  4. #4
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Automatically expanding cells to accomodate VLOOKUP results

    If I enter the data manually, the autofit works,
    so thats the concept of autofit :0
    It will autofit when something entered... not when any large data comes through formula which was already present there

    I dont think there is any way except VBA which will again do something like "Enter" - so either a human being presses enter or VBA presses enter. thanks.

    Regards,
    DILIPandey

    <click on below 'star' if this helps>

  5. #5
    Registered User
    Join Date
    11-22-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Automatically expanding cells to accomodate VLOOKUP results

    So, should I ask the same question in a VBA sub-forum then? I need the cells to adjust to the size of the incoming data.

  6. #6
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    195

    Re: Automatically expanding cells to accomodate VLOOKUP results

    Can you upload an example of what you need doing?

  7. #7
    Registered User
    Join Date
    11-22-2012
    Location
    Dublin, Ireland
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Automatically expanding cells to accomodate VLOOKUP results

    Thanks Eoghan.
    Here's a stripped out sample of what I'm trying to achieve. The user would enter a product name (as listed in column A, Sheet 2) into the yellow box on Sheet 1. This will bring up the relevant information. Since this is to be printed (and will be surrounded by lots of other data), I need the cells receiving the data (Sheet 1 A3 - A23) to dynamically change height to fit the data to be displayed. I've used Wrap Text as I do not want the data scrawling all across the page.
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    11-15-2012
    Location
    Edinburgh, Scotland
    MS-Off Ver
    Excel 2010
    Posts
    195

    Re: Automatically expanding cells to accomodate VLOOKUP results

    Hi r011in,

    Sorry for not getting back to you sooner. I've tried to open your file but unfortuantely can't. I think its because I'm trying to do this at work! Hopefully somebody else will be able to help you...

  9. #9
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Automatically expanding cells to accomodate VLOOKUP results

    Attached you will find a version of your workbook that will automatically re-size column A when a new chemical is chosen in cells E1 & F1.

    The automation is provided by macros.

    Macros must be enabled for this to work!
    Attached Files Attached Files
    Gary's Student

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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