Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Looping through worksheets

I need to loop through worksheets to complete a project but I cannot seem to
get a loop to work. How do I ensure that another worksheet is activated once
the loop has run through once.

I am using vba and office xp.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Looping through worksheets

Sub WorksheetLoop()
Dim wsName As String
Dim WS_Count As Integer
Dim i As Integer
WS_Count = _
ActiveWorkbook.Worksheets.Count
' Begin the loop.
For i = 1 To WS_Count
wsName = Worksheets(i).Name
MsgBox wsName
Next i
Worksheets("Sheet1").Select
End Sub

"Hermeticia" wrote:

I need to loop through worksheets to complete a project but I cannot seem to
get a loop to work. How do I ensure that another worksheet is activated once
the loop has run through once.

I am using vba and office xp.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Looping through worksheets

Thanks Mike
I tried the code and though the loops work the sheets are still not
activating. The first sheet through still activates, then the next ones name
comes up in the message box indicator but the sheet itself is not activating
beyond its name tab.
I need to process data on the sheet itself. This was the problem I struck
when trying to loop it earlier.

"Mike" wrote:

Sub WorksheetLoop()
Dim wsName As String
Dim WS_Count As Integer
Dim i As Integer
WS_Count = _
ActiveWorkbook.Worksheets.Count
' Begin the loop.
For i = 1 To WS_Count
wsName = Worksheets(i).Name
MsgBox wsName
Next i
Worksheets("Sheet1").Select
End Sub

"Hermeticia" wrote:

I need to loop through worksheets to complete a project but I cannot seem to
get a loop to work. How do I ensure that another worksheet is activated once
the loop has run through once.

I am using vba and office xp.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Looping through worksheets

Maybe this
Sub WorksheetLoop()
Dim wsName As String
Dim WS_Count As Integer
Dim i As Integer
WS_Count = _
ActiveWorkbook.Worksheets.Count
' Begin the loop.
For i = 1 To WS_Count
With Worksheets(i)
.Select
wsName = .Name
End With
MsgBox wsName
Next i

End Sub

"Hermeticia" wrote:

Thanks Mike
I tried the code and though the loops work the sheets are still not
activating. The first sheet through still activates, then the next ones name
comes up in the message box indicator but the sheet itself is not activating
beyond its name tab.
I need to process data on the sheet itself. This was the problem I struck
when trying to loop it earlier.

"Mike" wrote:

Sub WorksheetLoop()
Dim wsName As String
Dim WS_Count As Integer
Dim i As Integer
WS_Count = _
ActiveWorkbook.Worksheets.Count
' Begin the loop.
For i = 1 To WS_Count
wsName = Worksheets(i).Name
MsgBox wsName
Next i
Worksheets("Sheet1").Select
End Sub

"Hermeticia" wrote:

I need to loop through worksheets to complete a project but I cannot seem to
get a loop to work. How do I ensure that another worksheet is activated once
the loop has run through once.

I am using vba and office xp.

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
Looping Thru Worksheets Jay Excel Programming 2 April 12th 07 03:14 PM
Looping through worksheets RominallL Excel Programming 4 February 2nd 07 03:40 PM
Worksheets looping. Bob Phillips Excel Programming 0 December 6th 06 10:38 AM
looping through worksheets Alex ekster Excel Programming 1 July 21st 03 03:16 AM
looping through worksheets alex Excel Programming 0 July 20th 03 06:43 PM


All times are GMT +1. The time now is 11:43 AM.

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

About Us

"It's about Microsoft Excel"