Paste to all sheets except some with criteria

Solved/Closed
nzstorm Posts 6 Registration date Thursday 8 December 2011 Status Member Last seen 3 February 2013 - 27 Dec 2011 à 11:46
nzstorm Posts 6 Registration date Thursday 8 December 2011 Status Member Last seen 3 February 2013 - 28 Dec 2011 à 09:00
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 28 January 2010 Status Contributor Last seen 5 May 2022 766
27 Dec 2011 à 14:34
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