Adding a loop to a recorded macro

bcconnor

New Member
Joined
Aug 23, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have been searching this forum and found some similar posts in regards to adding a loop to a recorded macro and I can't seem to modify my macro to make it work. I apologize for posting such a similar topic.

I have a spreadsheet with about 300 records consisting of Lat1 Long1 Lat2 Long2 as my columns starting at C21:F21 and then C22:F22 and so on. I copy and paste the first row into an existing formula at J8:M8 and it calculates the azimuth and distance. which is in P50 and J42. I copy and paste the values into G21 and H21. Then I move to the next row and repeat the process. I recorded a macro for this but I can't seem to make this into loop for it to loop through all of the records. Can anyone help me with this?

Thanks in advanced!
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hi & welcome to MrExcel.
How about
VBA Code:
Sub bcconnor()
   Dim Cl As Range
   
   For Each Cl In Range("C21", Range("C" & Rows.Count).End(xlUp))
      Range("J8:M8").Value = Cl.Resize(, 4).Value
      Cl.Offset(, 4).Value = Range("P50").Value
      Cl.Offset(, 5).Value = Range("J42").Value
   Next Cl
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,517
Messages
6,125,287
Members
449,218
Latest member
Excel Master

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