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

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
64,087
Office Version
  1. 365
Platform
  1. Windows
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
 

Forum statistics

Threads
1,144,571
Messages
5,725,059
Members
422,590
Latest member
Mikeyyy

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
Top