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
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
19,119
Office Version
  1. 2013
Platform
  1. Windows
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.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
19,119
Office Version
  1. 2013
Platform
  1. Windows
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
 

Forum statistics

Threads
1,176,286
Messages
5,902,327
Members
434,962
Latest member
sgilmoreBBP

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