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

gregg777

New Member
Joined
Nov 22, 2024
Messages
2
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

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
From your pic "

Can't tell which is Col A or Col B or Col C, etc. etc.
Can't tell which cell is B3 pr B4
Can't tell which is Range("B4:B19")
Cannot find "='005- Machine Mechanical Kanbans'!R[1379]C4"
Where is Range("D73").Select

Pictures are nice but a working workbook is the best. Create a sample workbook without confidential information and post to a download website.
Show a "before" and "after" example of what you are seeking.
 
Upvote 0
Thank you Logit, as I said, first time poster, so I'll be sure to do that in future. Thanks.
 
Upvote 0

Forum statistics

Threads
1,224,847
Messages
6,181,313
Members
453,031
Latest member
Chris_1

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