countryfan_nt
Well-known Member
- Joined
- May 19, 2004
- Messages
- 765
Hello friends, hope all is well!
The below codes are working, but not as desired.
What is needed: a. Code moves from one sheet to the other.
b. Every time a new sheet is selected a countdown loop (5-0) in cell H2 takes place.
Once countdown reaches 0, a new sheet is selected. once last sheet in workbook is selected,
code goes back to 1st sheet from the right.
The problems: 1. When code is finished with last sheet, it does go to 1st sheet but briefly and countdown is not applied.
2. The countdown runs twice 5-0 in the last sheet; need it to run once only.
Your kind and support is always needed and appreciated in advance!
The below codes are working, but not as desired.
What is needed: a. Code moves from one sheet to the other.
b. Every time a new sheet is selected a countdown loop (5-0) in cell H2 takes place.
Once countdown reaches 0, a new sheet is selected. once last sheet in workbook is selected,
code goes back to 1st sheet from the right.
The problems: 1. When code is finished with last sheet, it does go to 1st sheet but briefly and countdown is not applied.
2. The countdown runs twice 5-0 in the last sheet; need it to run once only.
Your kind and support is always needed and appreciated in advance!
Code:
Sub MoveNext()
On Error Resume Next
If Not ActiveWorkbook Is ThisWorkbook Then Exit Sub
Sheets(ActiveSheet.Index + 1).Activate
Worksheets("count").Range("H2").Value = 6
Do Until Worksheets("count").Range("H2").Value = 1
If Worksheets("count").Range("H2").Value = 1 Then
Worksheets("count").Range("H2").Value = 6
Else
Worksheets("count").Range("H2").Value = Worksheets("count").Range("H2").Value - 1
Application.Wait (Now + TimeValue("00:00:01"))
End If
Loop
If Err.Number <> 0 Then
Sheets(2).Activate
Range("C3").Select
End If
End Sub
Code:
Sub MyMacro()
Call MoveNext
Application.OnTime Now + TimeValue("00:00:01"), "mymacro"
End Sub