Repeating macro for each cell in A (with offset)

anonymouslurker

New Member
Joined
Apr 2, 2020
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hi everyone! Right now I'm having troubles with how to repeat my macro for each cell in A. I have some offsets so it becomes very confusing.

Here is my code. I recorded the macro while ticking 'Use Relative References' on.

Hopefully someone can help me. Thank you very much in advance :)

VBA Code:
Sub MacroTest()
'
' MacroTest Macro
'
'
ActiveCell.Rows("1:1").EntireRow.Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
ActiveCell.Offset(1, 8).Range("A1:A83").Select
Selection.Copy
ActiveWindow.ScrollRow = 1
ActiveCell.Offset(-1, -2).Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
ActiveCell.Offset(1, -6).Range("A1:F1").Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(-1, 0).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(1, 0).Range("A1:J83").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp

End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
In that case when you get the error, click debug what line is highlighted?
 
Upvote 0
In that case you will need to step through the code.
Place the cursor anywhere in the code & keep pressing F8 until you get the error
 
Upvote 0
Thanks! I used Step Into under Debug and these below went yellow the first three times I do it, in order:

Sub anonymouslurker()
Ary = Sheets("Sheet2").Range("A1").CurrentRegion.Value2
ReDim Nary(1 To UBound(Ary), 1 To UBound(Ary, 2) + 80)

Then when I tried to Step Into a fourth time, it displays the error.
 
Upvote 0
Is sheet2 the sheet with your data?
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,886
Messages
6,122,093
Members
449,064
Latest member
Danger_SF

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