How to Repeat Macro for all rows with data

mrmattllewellyn

New Member
Joined
Nov 26, 2021
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hi All,

Please can you help! I'm new to Macro/VBA I have made the below and I would like to have this repeat on each row that has data in the spreadsheet.

VBA Code:
Range("F2").Select
    Selection.Copy
    Windows("Storage bin type calculator -Matt Copy.xlsm").Activate
    Range("C2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Windows("17.11.2021 Matt - Do Not Delete.xlsm").Activate
    Range("G2").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("Storage bin type calculator -Matt Copy.xlsm").Activate
    Range("C3").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Windows("17.11.2021 Matt - Do Not Delete.xlsm").Activate
    Range("H2").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("Storage bin type calculator -Matt Copy.xlsm").Activate
    Range("C4").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("H7").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("17.11.2021 Matt - Do Not Delete.xlsm").Activate
    Range("L2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Windows("Storage bin type calculator -Matt Copy.xlsm").Activate
    Range("P7").Select
    Application.CutCopyMode = False
    Selection.Copy
    Windows("17.11.2021 Matt - Do Not Delete.xlsm").Activate
    Range("M2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Range("L3").Select
End Sub
 
That code requires guessing the sheets when no sheets have been mentioned. I am aware how to do it when sheet names are known.
Yes I know. I was just showing the original poster a example.
If you have a script that would work for him feel free to post it here.
We are both just trying to help here.
 
Upvote 0

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Or for a range something like this:
VBA Code:
Sub Copy_Without_Selecting()
'Modified 11/30/2021  8:57:44 PM  EST
Workbooks("Book2").Sheets(1).Range("A1:G1").Copy: Workbooks("Book1").Sheets(2).Range("A6").PasteSpecial xlPasteValues
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,525
Members
449,088
Latest member
RandomExceller01

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