Results 1 to 6 of 6

Macro Autofill Dynamic Range with Multiple Data Sets

Threaded View

  1. #1
    Registered User
    Join Date
    08-03-2010
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    8

    Smile Macro Autofill Dynamic Range with Multiple Data Sets

    Hi, everyone!

    I have researched for the past three days on this matter and have not discovered a post similar, so I'm deciding to just post a new thread and ask myself.

    I am attempting to use macro to autofill two different ranges in the same spreadsheet from the command of a button. Since my ranges can change in the amount of rows that have data, I would like it to autofill for a dynamic range. I have tried many different codes, and I have one that works, but it doesn't work exactly as I had hoped. Here is my information:

    Range 1 is from F4:J50. I currently only have data from F4:J15.
    Range 2 is from F54:J80. I currently only have data from F54:J60.
    (*I will never need more than 50 rows per range)

    This is the code that I have currently:

    Sub Recalc1()
    
    'Recalc1 Macro
    
    Dim Lastrow As Long
    
    Lastrow = Range("F" & Rows.Count).End(xlUp).Row
    Range("F4:J4").AutoFill Destination:=Range("F4:J" & Lastrow)
    
    End Sub
    This code works perfectly except it stops at the end of Range 2. I need it to stop right before Range 2 and then start up again at the beginning Range 2. Is there any way that I can have the autofill stop at the end of each range, but still adjust to each dynamic range?

    I would post my spreadsheet, but I work for a government agency and it has classified information. If it would make it much easier for everyone, I can make an example spreadsheet using different data.
    I really appreciate your help, and I hope I have been clear.
    Thank you!
    Rae
    Last edited by AliveNThisMoment; 08-07-2010 at 03:48 PM.

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