Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Loop Question

I'm trying to loop through a workbook, test to see if the worksheet name is
numeric, and if so go to a subroutine(MoveData), if not, continue to the next
worksheet. I tried the following but can't get it to work, it has a problem
with the Next line. Anyone have any ideas?

Thanks, Alan

Sub Move_All_Data()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Select
If IsNumeric(ActiveSheet.Name) Then
MoveData
Else
Next ws
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default Loop Question

Try this modification which deletes the Else clause, cleans up the Next line,
and adusts the Then clause...

Sub Move_All_Data()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Select
If IsNumeric(ActiveSheet.Name) Then MoveData
Next 'ws
End Sub
--
Jay


"Alan P" wrote:

I'm trying to loop through a workbook, test to see if the worksheet name is
numeric, and if so go to a subroutine(MoveData), if not, continue to the next
worksheet. I tried the following but can't get it to work, it has a problem
with the Next line. Anyone have any ideas?

Thanks, Alan

Sub Move_All_Data()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Select
If IsNumeric(ActiveSheet.Name) Then
MoveData
Else
Next ws
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Loop Question

try this. Test and then uncomment the commented line

Sub eachnumericws()
For Each ws In Worksheets
If IsNumeric(ws.Name) Then MsgBox ws.Name 'TEST
'If IsNumeric(ws.Name) Then movedata
Next
End Sub


--
Don Guillett
SalesAid Software

"Alan P" wrote in message
...
I'm trying to loop through a workbook, test to see if the worksheet name
is
numeric, and if so go to a subroutine(MoveData), if not, continue to the
next
worksheet. I tried the following but can't get it to work, it has a
problem
with the Next line. Anyone have any ideas?

Thanks, Alan

Sub Move_All_Data()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Select
If IsNumeric(ActiveSheet.Name) Then
MoveData
Else
Next ws
End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Loop Question

Thanks Jay it looks like that did the trick.

Alan

"Jay" wrote:

Try this modification which deletes the Else clause, cleans up the Next line,
and adusts the Then clause...

Sub Move_All_Data()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Select
If IsNumeric(ActiveSheet.Name) Then MoveData
Next 'ws
End Sub
--
Jay


"Alan P" wrote:

I'm trying to loop through a workbook, test to see if the worksheet name is
numeric, and if so go to a subroutine(MoveData), if not, continue to the next
worksheet. I tried the following but can't get it to work, it has a problem
with the Next line. Anyone have any ideas?

Thanks, Alan

Sub Move_All_Data()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Select
If IsNumeric(ActiveSheet.Name) Then
MoveData
Else
Next ws
End Sub

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
Loop question N.F[_2_] Excel Discussion (Misc queries) 0 July 12th 07 08:02 PM
end with loop question Lee Hunter Excel Programming 2 November 3rd 05 08:14 PM
loop question choice[_2_] Excel Programming 7 October 30th 05 05:41 AM
One more loop question Patti[_5_] Excel Programming 11 June 6th 04 07:14 AM
another loop question Patti[_5_] Excel Programming 5 May 31st 04 07:43 AM


All times are GMT +1. The time now is 08:33 PM.

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"