+ Reply to Thread
Results 1 to 6 of 6

Adjusting the range of autofill Macros

  1. #1
    Registered User
    Join Date
    01-29-2021
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    5

    Question Adjusting the range of autofill Macros

    Hello - Is there a way to adjust the range for my Macro when I autofill a formula? For example I have a recorded macro for a trim function but obviously when I try and use the macro on a larger set of data the autofill range is only that of the original Macro recording. How can I adjust the range below to work with any amount of rows?

    [ActiveCell.FormulaR1C1 = "=TRIM(RC[-1])"
    Range("O2").Select
    Selection.AutoFill Destination:=Range("O2:O20303")
    Range("O2:O20303").Select
    Columns("O:O").Select]
    Last edited by Bino1581; 02-02-2021 at 01:57 PM.

  2. #2
    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
    44,447

    Re: Adjusting the range of autofill Macros

    Which column(s) is(are) fully populated? That is, with data in the last/bottom cell in the column.



    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional.)
    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


  3. #3
    Registered User
    Join Date
    01-29-2021
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    5

    Re: Adjusting the range of autofill Macros

    Tags added

    Columns A - Y are fully populated

  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
    44,447

    Re: Adjusting the range of autofill Macros

    Try:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-29-2021
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    5

    Re: Adjusting the range of autofill Macros

    Thank You!

  6. #6
    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
    44,447

    Re: Adjusting the range of autofill Macros

    You're welcome.


    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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. Auto adjusting macros to new workmap name.
    By Yannick90 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-03-2020, 12:58 PM
  2. [SOLVED] vba macros to apply formula for dynamic Auto Adjusting range references
    By Abdur_rahman in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-23-2019, 09:25 AM
  3. [SOLVED] Very small AutoFill macro showing "AutoFill methode of range class failed" why ?
    By nur2544 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-28-2013, 10:21 PM
  4. Print Range for Pivot Table Adjusting Range
    By mmicfinance in forum Excel General
    Replies: 0
    Last Post: 08-08-2012, 01:55 PM
  5. Need help adjusting this Formatting Macros
    By copleyr in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-15-2009, 10:27 AM
  6. Macros -How to autofill to end and select all
    By RikkeB in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-09-2009, 01:09 PM
  7. Recording macros with autofill
    By andyiain in forum Excel General
    Replies: 5
    Last Post: 06-19-2006, 10:35 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