Help creating a looping macro for data in the same format but with different number of rows?

Coyotex3

Active Member
Joined
Dec 12, 2021
Messages
496
Office Version
  1. 365
Platform
  1. Windows
Hello all I hope that you can all help me. I'm trying to create a macro that accomplishes the following.

Everytime I export data into Excel, I want it to copy whatever is on A7 until it reaches "Total." Then I want it to go 3 cells below the "Total" and copy whatever is on that cell until it reaches "Total." Then I want it to go 3 cells below the "Total" etc.

The next thing I would like is if possible for it to be dynamic. For example one day A7 will be empty until row A15 but one day it may be empty until row 25. I want it to always copy down until "Total" and then jump the three cells down.

I would like for the Macro to do that until there is no more data. I usually export files with about 2000 rows. Sometimes we have 100 different cells that need to be copied down. I'm trying to make that easier.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Probably the best place is sites like this one.

Glad we could help & thanks for the feedback
If I have a follow up question(trying to build on this macro) should I ask on this thread or create a new one?
 
Upvote 0
If it's a significantly different question, then it needs a new thread.
 
Upvote 0
How about
VBA Code:
Sub Coyotex()
   Dim Rng As Range
   For Each Rng In Range("B1", Range("B" & Rows.Count).End(xlUp)).SpecialCells(xlConstants).Areas
      Rng.Offset(, -1).FillDown
   Next Rng
End Sub
Hey sorry, one question, Is there a way of tweaking this a bit. When running the macro it is picking up the header in "Column 1" and copying that down. I'm trying to keep it so it doesn't select the header. Any tips?
 
Upvote 0
Thank you Once again. You single handedly just freed up about 6 hours of my week.
 
Upvote 0
Just change the B1 to B2
Hey another question. Is there a way I can tweak this more so that it copies both columns A and B and the data is displayed like this?

1639354007512.png
 
Upvote 0
Trying to copy the values on Columns A and B to fill the rest of the data set. I would like for the macro to copy A2 and B2 and stop at A6 and B6 and then copy A10 and B10 until next non-blank etc.
 
Last edited by a moderator:
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,269
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top