Copy and Paste Value Macro - Starting to the right of a specific worksheet.

csch123

New Member
Joined
Mar 6, 2013
Messages
32
Hello,

I currently use a macro that copies and pastes value on each worksheet. I have recently implemented new worksheets that I do not want to be copied and paste valued. If I was to input a sheet entitled "Start" and have the macro only copy and paste value all sheets to the right of that, how would I need to change my code?

Sub CopyPasteValueAll()
'Copies and pastes values in all sheets of the active workbook
Dim Sh As Worksheet
For Each Sh In ThisWorkbook.Worksheets
If Sh.Visible = True Then
Sh.Activate
Sh.Cells.Copy
Sh.Range("A1").PasteSpecial Paste:=xlValues
Sh.Range("A1").Select
End If
Next Sh
Application.CutCopyMode = False
End Sub



Thanks!
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Try this:
Code:
Sub CopyPasteValueAll()
'Copies and pastes values in all sheets of the active workbook
Dim Sh As Worksheet, n As Long

On Error Resume Next
n = Sheets("Start").Index
On Error GoTo 0
If n = 0 Then
    MsgBox "A Sheet named Start doesn't exist"
    Exit Sub
End If
For Each Sh In ThisWorkbook.Worksheets
If Sh.Visible = True And Sh.Index > n Then
Sh.Activate
Sh.Cells.Copy
Sh.Range("A1").PasteSpecial Paste:=xlValues
Sh.Range("A1").Select
End If
Next Sh
Application.CutCopyMode = False
End Sub
 
Upvote 0
in your code chnag

this
Code:
If Sh.Visible = True Then
to this
Code:
If Sh.Visible = True And Sh.Name <> "Start" Then
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,387
Members
448,956
Latest member
JPav

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