+ Reply to Thread
Results 1 to 2 of 2

Autofit and Vlookup

  1. #1
    Registered User
    Join Date
    05-11-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    8

    Autofit and Vlookup

    Hi Everyone,

    I am a beginner to all of this so I apologise if I use the wrong terminology or I'm a bit slow with it all.
    Anyway, basically I am trying to bring values from a table in another workbook into a cell using VLOOKUP.
    I have mastered that but I cant seem to autofit the cell to fit the result which enters the cell (sometimes a paragraph long, other times nothing at all depending on the "customer" cell).
    This means that there is a very large gap left behind when a large paragraph that I have accomodated for disappears.

    I have realised that if there were a way to automatically autofit the cell to fit the size of the text then it wouldn't leave large gaps in the document.

    I found a help topic on this very problem and attempted to use the VB code without success.
    I have a feeling this is because there are certain words that need to be replaced to suit my excel document.
    This is what I tried to insert :

    Option Explicit
    Private Sub Worksheet_Calculate()
    me.Unprotect
    Me.Rows("182").AutoFit
    me.protect
    End Sub

    I tried this and it didnt work.
    I tried changing the word "calculate" to the name of my worksheet "Data" which holds the tables used for the Vlookup.
    I tried not using the unprotect/protect lines (not sure if they are needed)
    I am also not sure if the line regarding which row to autofit has the correct syntax. I only want row 182 to autofit in order to allow a large paragraph or just one word.
    I didnt change the first line as I assume this is necessary.

    Could you please help me out.
    Im sure this is a simple one for you guys.
    As you can see I will need to be spoon fed through this one.

    Thanks in advance

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Autofit and Vlookup

    Please Login or Register  to view this content.
    just put in the worksheet module
    this does cols a and b
    for one column
    Please Login or Register  to view this content.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

+ 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