View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jeffrey R Dempsey Jeffrey R Dempsey is offline
external usenet poster
 
Posts: 1
Default Looping with Excel Forms

Hi All,

This might be a dumb question (and yes, there are some...) but how do I loop
through a bunch of sheets, and I have a UserForm that I need displayed for
each sheet. Here is my code:

For Each CurSheet In ThisWorkbook.Sheets
shName = Val(Right(CurSheet.Name, 3))
If shName = ThisWorkbook.Sheets("Configuration").Range("P3").V alue
And shName <= ThisWorkbook.Sheets("Configuration").Range("Q3").V alue Then
ThisWorkbook.Sheets(CurSheet.Name).Activate
frmWorkEntry.Show (0)
End If
Next CurSheet

OK, it just loops through all of the sheets and ends at the last one. I
have a 29 sheets (and it can get larger) named XXX401 through XXX430, and
the sheets are not aligned in numerical order.

I do not want to go modal, because there is information on the sheets the
users may need to complete the current sheet.

Here is the sequence of events:
1. Start Loop
2. Show user form for an item
3. Display frmWorkEntry, and let the user enter the work done for that
item.
4. Validate Work entry
5. When the 'Next' button is pressed, populate current sheet, activate next
sheet (validated to ensure that it is a correct sheet for work entry), and
loop back to step 2.
6. When there are no more work forms, quit loop.

Is there something that I am missing?

Thanks,

Jeff