+ Reply to Thread
Results 1 to 3 of 3

Code to auto populate a relative formula into a column

  1. #1
    Forum Contributor
    Join Date
    03-30-2007
    Location
    London, UK
    MS-Off Ver
    Microsoft Office 2007
    Posts
    317

    Smile Code to auto populate a relative formula into a column

    Hi All

    I have a report that I run off a database and extract to Excel.

    It has 3 fields: Title; FirstName; LastName. For example sake lets say they are in columns A, B, C. Now in D I have a fieldname of FullName and in D2 onwards the formula: =A2&" "&B2&" "&C2.

    Now I currently manually type the formula and drag it down to the same row as the last entry in the first 3 columns so that I get the full title in one cell.

    I wanted to know how I could enter the the formula above in column D so that it automatically does this for me?

    I tried to record a Macro as a test for column D setting the field name in D1 and the formula in D2 and got the following:
    Please Login or Register  to view this content.
    How can I copy this down in a Macro only to the last populated row in columns A, B & C?

    I have a piece of code to highlight a range from A2 to the last entry as so:
    Please Login or Register  to view this content.
    How can I use the above code as the range that needs the formula adding in column D as I am worried if I don't measure the range the macro will simply populate until it hits row 65536?

    I would be grateful for some guidance.

    Thanks.
    Last edited by Zyphon; 03-13-2009 at 01:19 PM.
    Best Regards.

    Michael
    -----------------------------------
    Windows Vista, Microsoft Office 2007

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Code to auto populate a relative formula into a column

    I don't quite understand the VBA given D reference, perhaps:

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    03-30-2007
    Location
    London, UK
    MS-Off Ver
    Microsoft Office 2007
    Posts
    317

    Thumbs up Re: Code to auto populate a relative formula into a column

    Thank you so much DonkeyOte, this worked has worked perfectly and is exactly what I wanted.

    It works much better than the code I was trying to use below. I couldn't find a way to insert a space between the 3 fields so I was getting "MrJohnDoe"

    Please Login or Register  to view this content.
    Thank you for your help it I really appreciate it.

+ 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