swaink
Active Member
- Joined
- Feb 15, 2002
- Messages
- 432
Hi All
I am rather new to the use of CASE statements and have found myself in need of assistance please.
I have put together a spreadsheet which has many individual macros to perform, I then added a progress bar which works well except I have one macro which runs for some considerable time fetching info.
I introduced some additional lines to that macro to calculate what stage it was at, this works ok but I am now trying to streamline the code to improve on it using CASE
I use the calulated figures to update the progress bar for example :-
I have 10 mycounts plus the lines above so its quite large and I am looking to use CASE to simplify the whole thing but I can't get it to work.
My attempt at using CASE looks like this below:-
Any and al help would be appreciated thank you
Regards
Kevin
I am rather new to the use of CASE statements and have found myself in need of assistance please.
I have put together a spreadsheet which has many individual macros to perform, I then added a progress bar which works well except I have one macro which runs for some considerable time fetching info.
I introduced some additional lines to that macro to calculate what stage it was at, this works ok but I am now trying to streamline the code to improve on it using CASE
I use the calulated figures to update the progress bar for example :-
Code:
If lngProcessingRow = mycount1 Then
PctDone = 50
With UserForm1
.Frameprogress.Caption = Format(PctDone, "0")
.Labelprogress.Width = PctDone * 3
.Label1.Caption = "Off we go time for a story"
End With
' The DoEvents statement is responsible for the form updating
DoEvents
End If
I have 10 mycounts plus the lines above so its quite large and I am looking to use CASE to simplify the whole thing but I can't get it to work.
My attempt at using CASE looks like this below:-
Code:
mycase = lngProcessingRow
Select Case mycase
Case Is = mycount1 'this would represent a value say row 10'
With UserForm1
PctDone = 50 ' This represents the percentage overall that has been completed'
.Labelprogress.Width = PctDone * 3
.Label1.Caption = "Off we go time for a story"
DoEvents
Case Is = mycount2 'this would represent a value say row 20'
With UserForm1
PctDone = 55
.Labelprogress.Width = PctDone * 3
.Label1.Caption = "Or you could have time for a coffee"
DoEvents
Case Is = mycount3 etc up to case 10
Any and al help would be appreciated thank you
Regards
Kevin
Last edited by a moderator: