Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 364
Default need some help with selecting a sheet in a loop again

i have tabs renamed, so i am using this

For c = 2 To 13

Sheet2.Range("C5:E5").Copy
Range("C5:E5").PasteSpecial xlPasteValues, xlPasteSpecialOperationAdd '
(this range is on sheet1)
Next c


i want to replace the 2 with the c so it selects the range of sheets from 2
to 13.


any help appreciated
--


Gary



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default need some help with selecting a sheet in a loop again

For c = 2 To 13

Worksheet("Sheet" & c).Range("C5:E5").Copy
Range("C5:E5").PasteSpecial xlPasteValues, xlPasteSpecialOperationAdd '
(this range is on sheet1)
Next c


--
HTH

Bob Phillips

"Gary Keramidas" wrote in message
...
i have tabs renamed, so i am using this

For c = 2 To 13

Sheet2.Range("C5:E5").Copy
Range("C5:E5").PasteSpecial xlPasteValues, xlPasteSpecialOperationAdd '
(this range is on sheet1)
Next c


i want to replace the 2 with the c so it selects the range of sheets from

2
to 13.


any help appreciated
--


Gary





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 364
Default need some help with selecting a sheet in a loop again

bob:

this doesn't seem to work. could be 2 reasons:

1. i have the tabs renamed, doesn't that make a difference when using the
worksheet function?
2. also, isn't there a space or something in the number that c represents?
if i combine them and use a msgbox to display. it shows sheet 2

--


Gary


"Bob Phillips" wrote in message
...
For c = 2 To 13

Worksheet("Sheet" & c).Range("C5:E5").Copy
Range("C5:E5").PasteSpecial xlPasteValues, xlPasteSpecialOperationAdd '
(this range is on sheet1)
Next c


--
HTH

Bob Phillips

"Gary Keramidas" wrote in message
...
i have tabs renamed, so i am using this

For c = 2 To 13

Sheet2.Range("C5:E5").Copy
Range("C5:E5").PasteSpecial xlPasteValues, xlPasteSpecialOperationAdd '
(this range is on sheet1)
Next c


i want to replace the 2 with the c so it selects the range of sheets from

2
to 13.


any help appreciated
--


Gary







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 364
Default need some help with selecting a sheet in a loop again

here's the error:

compile error,
sub or function not defined

worksheet is highlighted

--


Gary


"Bob Phillips" wrote in message
...
For c = 2 To 13

Worksheet("Sheet" & c).Range("C5:E5").Copy
Range("C5:E5").PasteSpecial xlPasteValues, xlPasteSpecialOperationAdd '
(this range is on sheet1)
Next c


--
HTH

Bob Phillips

"Gary Keramidas" wrote in message
...
i have tabs renamed, so i am using this

For c = 2 To 13

Sheet2.Range("C5:E5").Copy
Range("C5:E5").PasteSpecial xlPasteValues, xlPasteSpecialOperationAdd '
(this range is on sheet1)
Next c


i want to replace the 2 with the c so it selects the range of sheets from

2
to 13.


any help appreciated
--


Gary







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default need some help with selecting a sheet in a loop again

Hi Gary,

Try something like:

Sub TestIt()
Dim c As Long
Dim sh As Worksheet
For c = 3 To ActiveWorkbook.Sheets.Count
For Each sh In ActiveWorkbook.Worksheets
If sh.CodeName = "Sheet" & c Then
'do something. e.g.:
MsgBox sh.Name
End If
Next sh
Next c

End Sub

---
Regards,
Norman



"Gary Keramidas" wrote in message
...
i have tabs renamed, so i am using this

For c = 2 To 13

Sheet2.Range("C5:E5").Copy
Range("C5:E5").PasteSpecial xlPasteValues, xlPasteSpecialOperationAdd '
(this range is on sheet1)
Next c


i want to replace the 2 with the c so it selects the range of sheets from
2 to 13.


any help appreciated
--


Gary







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default need some help with selecting a sheet in a loop again

Hi Gary,

Change:

For c = 3 To ActiveWorkbook.Sheets.Count


to:

For c = 2 To 13


I forgot to amend my test code!

---
Regards,
Norman



"Norman Jones" wrote in message
...
Hi Gary,

Try something like:

Sub TestIt()
Dim c As Long
Dim sh As Worksheet
For c = 3 To ActiveWorkbook.Sheets.Count
For Each sh In ActiveWorkbook.Worksheets
If sh.CodeName = "Sheet" & c Then
'do something. e.g.:
MsgBox sh.Name
End If
Next sh
Next c

End Sub

---
Regards,
Norman



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default need some help with selecting a sheet in a loop again

If you have renamed them that is difficult, we need to use the codename
then.

For c = 2 To 13
Worksheet(ThisWorkbook.VBProject.VBComponents("She et" & c) _
.Properties("Name").Value).Range("C5:E5").Copy
Range("C5:E5").PasteSpecial xlPasteValues,
xlPasteSpecialOperationAdd
Next c


--
HTH

Bob Phillips

"Gary Keramidas" wrote in message
...
bob:

this doesn't seem to work. could be 2 reasons:

1. i have the tabs renamed, doesn't that make a difference when using the
worksheet function?
2. also, isn't there a space or something in the number that c represents?
if i combine them and use a msgbox to display. it shows sheet 2

--


Gary


"Bob Phillips" wrote in message
...
For c = 2 To 13

Worksheet("Sheet" & c).Range("C5:E5").Copy
Range("C5:E5").PasteSpecial xlPasteValues, xlPasteSpecialOperationAdd '
(this range is on sheet1)
Next c


--
HTH

Bob Phillips

"Gary Keramidas" wrote in message
...
i have tabs renamed, so i am using this

For c = 2 To 13

Sheet2.Range("C5:E5").Copy
Range("C5:E5").PasteSpecial xlPasteValues, xlPasteSpecialOperationAdd '
(this range is on sheet1)
Next c


i want to replace the 2 with the c so it selects the range of sheets

from
2
to 13.


any help appreciated
--


Gary









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ignoring Sheet in For Each Loop ExcelMonkey[_190_] Excel Programming 3 March 3rd 05 10:09 PM
Jump out of Do Loop on sheet change Paul Excel Programming 2 May 14th 04 04:21 PM
Loop - for each sheet not working? Shetty Excel Programming 6 January 15th 04 02:22 PM
Another loop & sheet question steve Excel Programming 4 November 25th 03 02:12 PM
Excluding sheet in loop david Excel Programming 2 July 31st 03 03:18 AM


All times are GMT +1. The time now is 07:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"