Macro or VBA code for repeating a task but with different cell information each time

gregg777

New Member
Joined
Nov 22, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi all,
First post here, so thanks for reading.
I have a table that I done lots of work on but need to alter it by adding lots of extra rows to certain worksheets within the Excel file. Because I can't start over, I need to find a way to automate what I can easily do manually to speed up the process. I have over 2000 lines to do and it will take me a long time. I have recorded a Macro and it works great- for the one cell I recorded it for!
Ideally, I could do with the cell I take the data from to automatically fill in a certain part of the code so I can just run that code in the next cell, then the next, then the next etc (OR maybe all at once or in batches if possible).

Does anyone have any ideas how to do this.

The code I have that works great manually (for only the cell I record it on) is this...

-------------------------------------

VBA Code:
Sub AutoTranspose()
'
' AutoTranspose Macro
'

'
    Range("B4").Select
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = "='005- Machine Mechanical Kanbans'!R[1379]C4"
    Range("B4").Select
    Selection.AutoFill Destination:=Range("B4:B19"), Type:=xlFillDefault
    Range("B4:B19").Select
    Selection.Copy
    Range("D73").Select
    Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=True
End Sub

----------------------------------


1732288718958.png
 
Last edited by a moderator:

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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