ignoring certain tab names

R

Rob P

I have the following code to create a summary sheet looping through
multiple worksheets

how do I add in lines to NOT include sheets named:
data
template
1 day moves
3 day moves




Sub MakeSummary_1day()
Dim J As Long
Dim I As Long
Dim Tab_Name As String
Sheets.Add.Name = "1 day moves"
Sheets("1 day moves").Select
Range("$A$3:$EK$104").Value = ""
J = 3
For I = 2 To Sheets.Count

Range("A" + Format(J)).FormulaR1C1 = Tab_Name
Range("B" + Format(J)).FormulaR1C1 = "='" + Tab_Name + "'!
R5C11"
Range("C" + Format(J)).FormulaR1C1 = "='" + Tab_Name + "'!
R5C12"
Range("D" + Format(J)).FormulaR1C1 = "='" + Tab_Name + "'!
R5C13"


J = J + 1

Next I

End Sub




MANY THANKS
 
R

Rob P

Perhaps stating the sheets you want to ignore like this:

Sub MakeSummary_1day()
Dim J As Long
Dim I As Long
Dim Tab_Name As String
Sheets.Add.Name = "1 day moves"
Sheets("1 day moves").Select
Range("$A$3:$EK$104").Value = ""
J = 3
For I = 2 To Sheets.Count
If Sheet.Name = "Sheet1" Or Sheet.Name = "Sheet2" Then GoTo Nxt
Range("A" + Format(J)).FormulaR1C1 = Tab_Name
Range("B" + Format(J)).FormulaR1C1 = "='" + Tab_Name + "'!"
R5C11 ""
Range("C" + Format(J)).FormulaR1C1 = "='" + Tab_Name + "'!"
R5C12 ""
Range("D" + Format(J)).FormulaR1C1 = "='" + Tab_Name + "'!"
R5C13 ""

J = J + 1
Nxt:
Next I
End Sub

Rob P;309469 Wrote:> I have the following code to create a summary sheet looping through


Code:
--------------------
  >   >  
  > Sub MakeSummary_1day()
  > Dim J As Long
  > Dim I As Long
  > Dim Tab_Name As String
  > Sheets.Add.Name = "1 day moves"
  > Sheets("1 day moves").Select
  > Range("$A$3:$EK$104").Value = ""
  > J = 3
  > For I = 2 To Sheets.Count
  >
  > Range("A" + Format(J)).FormulaR1C1 = Tab_Name
  > Range("B" + Format(J)).FormulaR1C1 = "='" + Tab_Name + "'!
  > R5C11"
  > Range("C" + Format(J)).FormulaR1C1 = "='" + Tab_Name + "'!
  > R5C12"
  > Range("D" + Format(J)).FormulaR1C1 = "='" + Tab_Name + "'!
  > R5C13"
  >
  >
  > J = J + 1
  >
  > Next I
  >
  > End Sub
  >
--------------------




--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)

I cannot get this to work...
 
R

Rob P

I cannot get this to work...- Hide quoted text -

- Show quoted text -

I used this to get it working:

If Sheets(I).Name = "data" Or Sheets(I).Name = "1 day moves" Or Sheets
(I).Name = "3 day moves" Then GoTo Nxt
 
R

Rob P

I cannot get this to work...- Hide quoted text -

- Show quoted text -

If Sheets(I).Name = "data" Or Sheets(I).Name = "1 day moves" Or Sheets
(I).Name = "3 day moves" Then GoTo Nxt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top