+ Reply to Thread
Results 1 to 4 of 4

How to fill a column with data if the column has a variable length?

  1. #1
    Registered User
    Join Date
    06-16-2012
    Location
    Mougins,France
    MS-Off Ver
    Excel 2007
    Posts
    10

    How to fill a column with data if the column has a variable length?

    Hello Excel gurus,

    I'm working a bit with recording macros. So, just simple "start recording->click away->stop recording" stuff.
    I am trying to do the following:

    1. Insert a formula in field. Let's say column C is the sum of column A+B. So I click on C1 and type in the formula =SUM(A1:B1)
    2. I drag the formula from C1 all the way down to the end of the table. When I say end of the table, I mean "the last row that contains some data in columns A/B)"

    The problem: When I record the macro with 10 lines in my sheet, and I execute the macro, I will get the formula copied for 10 lines. Fine. But.. the length of my table may vary. It may be 20, 30 or 1000 lines. So how do I tell the macro to "copy the formula in C1 all the way down till the last valid row?"

    Thank you

  2. #2
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: How to fill a column with data if the column has a variable length?

    You could use
    Please Login or Register  to view this content.
    - Battle without fear gives no glory - Just try

  3. #3
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: How to fill a column with data if the column has a variable length?

    Note1: in the previous macro, column "A" is used as reference, the first row is 1
    Note2: to fill down manually, you don't need to " drag the formula from C1 all the way down to the end of the table."
    select C1 and place the cursor on the right bottom corner
    the cursor will change to a cross
    do a double left clic

  4. #4
    Registered User
    Join Date
    06-16-2012
    Location
    Mougins,France
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: How to fill a column with data if the column has a variable length?

    That's great! Even after 20+ years of excel, I didn't know the "double-click-paste-till-end-of-table" shortcut. That does the trick. Thanks

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro to Sum several data sets(variable length) in the same column
    By mahtabshaikh in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-25-2012, 08:34 AM
  2. VBA: Calculate average based on data from previous column, variable length
    By zeno1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-01-2012, 07:26 PM
  3. Replies: 6
    Last Post: 04-14-2012, 04:07 AM
  4. Last Cell in a Variable Length Column
    By akj375 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-11-2011, 10:25 PM
  5. Another Auto Fill variable length column
    By BEEJAY in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-22-2006, 12:00 PM
  6. [SOLVED] Autosum a variable column length using VB
    By sid in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2006, 11:10 AM
  7. Sum a Column of Variable length
    By Chris G in forum Excel General
    Replies: 4
    Last Post: 11-07-2005, 08:30 AM
  8. Sum a column of variable length?
    By Brian in forum Excel General
    Replies: 5
    Last Post: 02-03-2005, 11:06 AM

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