VBA Loop for data transfer

Broga1981

New Member
Joined
May 5, 2017
Messages
9
Hi guys, very new to VBA so please go easy on me as I am a complete beginner (just managed to work out how to transfer from one sheet to another).

One of the reports I run has a messed up format which puts staff names in column A but at every 5 rows (it includes other data in the other rows but not names).
What is the simplest way to transfer the names at these intervals A1, A6, A11, A16 etc to another sheet and also have it be dynamic.

This may be beyond my skill set but I have identified the need to try and move it around. Any help and simple explanations will be appreciated. Thank you.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
There is 100% an easier way than doing it like this, i just dont know how haha

Worksheets("RAW").Range("A1").Copy Worksheets("Master").Range("A2")
Worksheets("RAW").Range("A6").Copy Worksheets("Master").Range("A3")
Worksheets("RAW").Range("A11").Copy Worksheets("Master").Range("A4")
 
Upvote 0
Try something like this:
VBA Code:
    Dim lr As Long
    Dim r As Long
  
'   Find last row in column A with data
    lr = Cells(Rows.Count, "A").End(xlUp).Row
  
'   Loop through all rows in column A starting at row 1 and going every 5 rows
    For r = 1 To lr Step 5
'       Copy value from column A
        Cells(r, "A").Copy ...
    Next r
obviously, you would need to complete the paste portion of the copy command, but this gives you the structure.
 
Upvote 0
Solution
You are welcome.
Glad I was able to help!
 
Upvote 0
You have helped greatly, and there is enough left for me to learn on my own also. Perfect :)
Excellent!
Feel free to post back if you run into any issues getting it to work the way you need.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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