+ Reply to Thread
Results 1 to 5 of 5

Can I autofill using a Variable Range?

Hybrid View

  1. #1
    Registered User
    Join Date
    01-12-2020
    Location
    Philadelphia, PA
    MS-Off Ver
    2016
    Posts
    97

    Can I autofill using a Variable Range?

    I have a fairly large workbook with a lot of formulas. My spreadsheet involves pasting data into fields A2:K_(?) . The formulas are in AA:AK.

    The "?" is because the data could be anywhere from 200 lines up to 8000 lines.

    In an effort to reduce size (and memory on an old laptop), I would like to load the data in Columns A:K as usual, use COUNTA to determine how many lines of data there are, and then copy the formulas from AA2:AK2 into as many rows as needed.

    I have created a cell to contain COUNTA (A2:A10000), and have created another cell to say "AA2:AK __(whatever the COUNTA is)__", but then when I try to use "RANGE" and "VALUE" in macro to pull the data from that cell, I get an error.

    Is there a way to do this? Thanks in advance.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,743

    Re: Can I autofill using a Variable Range?

    Probably, but it will be easier for us to help you if ....

    .....

    Fast answers need visual help. Please read the yellow banner at the top of this page on how to attach a file.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    01-12-2020
    Location
    Philadelphia, PA
    MS-Off Ver
    2016
    Posts
    97

    Re: Can I autofill using a Variable Range?

    As you wish
    Attached Files Attached Files
    Last edited by CriticalMass048; 09-22-2022 at 12:20 PM.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,440

    Re: Can I autofill using a Variable Range?

    Try:

    Dim lLR As Long
    lLR = Range("A" & Rows.Count).End(xlUp).Row
    Range("J1:J" & lLR).Formula = _
           "=SUM(A1:H1)"
    Doesn't need cell N1
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Registered User
    Join Date
    01-12-2020
    Location
    Philadelphia, PA
    MS-Off Ver
    2016
    Posts
    97

    Re: Can I autofill using a Variable Range?

    TMS,

    Thank you for the prompt response. To my Rookie eye, it looks like you're actually entering a specific formula into each cell in J.

    It's definitely a big help already, but if there are more formulas in columns K and L as well, do I need to do a seperate "FORMULA =" line for each column? I was hoping for generic macro that would copy the formula whatever it may be.

    Sorry... 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] How do you use a variable range with autofill?
    By max3732 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-08-2022, 12:09 PM
  2. Vba to autofill variable range across workbook
    By max8719 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-17-2016, 10:48 AM
  3. [SOLVED] Autofill Variable Range
    By efarkouh in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-23-2014, 02:32 PM
  4. Autofill with a variable range
    By Jbm444 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-23-2010, 04:37 PM
  5. VBA .Range autofill variable column same row
    By Zaeguzah in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 06-04-2010, 07:24 AM
  6. autofill in macro range is constant- how can I code to be a variable range?
    By mcg7@ntrs.com in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-20-2010, 12:44 AM
  7. autofill variable range
    By PaulSin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-29-2006, 08:52 PM

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