help adapting recorded macro.

coxycoxycoxy

Board Regular
Joined
Apr 22, 2009
Messages
165
Hi All

Have record a piece of code using the macro recorder, that copies a range of cells in a worksheet, and then pastes links to those cells in another worksheet.

would some one please be kind enough to show me how to adapt the code so that is does the same for every work sheet in the work book.
Code:
Sheets
   ("SH 0.25X457X305MM ALLOY 42 HH ").Select
    Range("B9").Select
    Selection.Copy
    Sheets("CONTROL.SHEET").Select
    Range("B8").Select
    ActiveSheet.Paste Link:=True
    Sheets("SH 0.25X457X305MM ALLOY 42 HH ").Select
    Range("E3").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("CONTROL.SHEET").Select
    Range("C8").Select
    ActiveSheet.Paste Link:=True
    Sheets("SH 0.25X457X305MM ALLOY 42 HH ").Select
    Range("O3").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("CONTROL.SHEET").Select
    Range("G8").Select
    ActiveSheet.Paste Link:=True
    Sheets("SH 0.25X457X305MM ALLOY 42 HH ").Select
    Range("Q5:R5").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("CONTROL.SHEET").Select
    Range("I8").Select
    ActiveSheet.Paste Link:=True
    Sheets("SH 0.25X457X305MM ALLOY 42 HH ").Select
    Range("S5").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("CONTROL.SHEET").Select
    Range("K8").Select
    ActiveSheet.Paste Link:=True
    Sheets("SH 0.25X457X305MM ALLOY 42 HH ").Select
    Range("Q6:R6").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("CONTROL.SHEET").Select
    Range("Q8:R8").Select
    ActiveSheet.Paste Link:=True
    Range("I20").Select
End Sub
Thanks in advance

Mark
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi All

Have record a piece of code using the macro recorder, that copies a range of cells in a worksheet, and then pastes links to those cells in another worksheet.

would some one please be kind enough to show me how to adapt the code so that is does the same for every work sheet in the work book.
Code:
Sheets
   ("SH 0.25X457X305MM ALLOY 42 HH ").Select
    Range("B9").Select
    Selection.Copy
    Sheets("CONTROL.SHEET").Select
    Range("B8").Select
    ActiveSheet.Paste Link:=True
    Sheets("SH 0.25X457X305MM ALLOY 42 HH ").Select
    Range("E3").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("CONTROL.SHEET").Select
    Range("C8").Select
    ActiveSheet.Paste Link:=True
    Sheets("SH 0.25X457X305MM ALLOY 42 HH ").Select
    Range("O3").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("CONTROL.SHEET").Select
    Range("G8").Select
    ActiveSheet.Paste Link:=True
    Sheets("SH 0.25X457X305MM ALLOY 42 HH ").Select
    Range("Q5:R5").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("CONTROL.SHEET").Select
    Range("I8").Select
    ActiveSheet.Paste Link:=True
    Sheets("SH 0.25X457X305MM ALLOY 42 HH ").Select
    Range("S5").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("CONTROL.SHEET").Select
    Range("K8").Select
    ActiveSheet.Paste Link:=True
    Sheets("SH 0.25X457X305MM ALLOY 42 HH ").Select
    Range("Q6:R6").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("CONTROL.SHEET").Select
    Range("Q8:R8").Select
    ActiveSheet.Paste Link:=True
    Range("I20").Select
End Sub
Thanks in advance

Mark

Maybe this will give you some ideas:

Code:
Sub coxycoxycoxy()
Application.ScreenUpdating = False
Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets


If ws.Name <> "SH 0.25X457X305MM ALLOY 42 HH " Then

Sheets("SH 0.25X457X305MM ALLOY 42 HH ").Range("B9").Copy
ws.Select
Range("B8").Select
ActiveSheet.Paste Link:=True
Sheets("SH 0.25X457X305MM ALLOY 42 HH ").Range("E3").Copy
ws.Select
Range("C8").Select
ActiveSheet.Paste Link:=True
Sheets("SH 0.25X457X305MM ALLOY 42 HH ").Range("O3").Copy
ws.Select
Range("G8").Select
ActiveSheet.Paste Link:=True
Sheets("SH 0.25X457X305MM ALLOY 42 HH ").Range("Q5:R5").Copy
ws.Select
Range("I8").Select
ActiveSheet.Paste Link:=True
Sheets("SH 0.25X457X305MM ALLOY 42 HH ").Range("S5").Copy
ws.Select
Range("K8").Select
ActiveSheet.Paste Link:=True
Sheets("SH 0.25X457X305MM ALLOY 42 HH ").Range("Q6:R6").Copy
ws.Select
Range("Q8:R8").Select
ActiveSheet.Paste Link:=True

End If

Next ws

Application.ScreenUpdating = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,531
Messages
6,179,379
Members
452,907
Latest member
Roland Deschain

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