Paste to all sheets except some with criteria

Solved/Closed
nzstorm Posts 6 Registration date Thursday December 8, 2011 Status Member Last seen February 3, 2013 - Dec 27, 2011 at 11:46 AM
nzstorm Posts 6 Registration date Thursday December 8, 2011 Status Member Last seen February 3, 2013 - Dec 28, 2011 at 09:00 AM
Hi,

How can I make a macro paste copied data into some sheets of a worksheet but not other sheets. For example, I have 10 sheets in my worksheet that data need to be pasted in them , however, I have a few sheets that I don't want the data to be pasted in them (they have static names).

Here's the related portion of code that I have right now. This code will paste the data to every sheet. I would like add a condition that will not paste the data if the sheet name is "Data to Copy", "Main" and "Summary".

For i = 1 To Sheets.Count
Sheets(i).Select
Range("H400").Select
ActiveSheet.Paste
Range("A1").Select
Next

Any help would be greatly appreciated.


2 responses

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Dec 27, 2011 at 02:34 PM
you need to put a IF statement or a select statement


    For i = 1 To Sheets.Count
        sheetName = Sheets(i).Name
        Select Case sheetName
            Case Is = "Sheet1", "Sheet2", "Skip me"
                ' no action
            Case Else
                Sheets(i).Select
                Range("H400").Select
                ActiveSheet.Paste
                Range("A1").Select
        End Select
    Next
0