combigning VBA Code

DrPancho

Board Regular
Joined
Jun 12, 2015
Messages
80
Hi,
Im a little stuck trying to organise the below snippits of code to work.

I want the workbook to toggle beetween worksheets at a fast rate, say 0.3sec but not sure how i should be organising the code.

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True
MsgBox "Ah ah ah, you didn't say the magic word!", , "Your request has been denied!"
  
Workbooks("TEST.xlsm").Sheets("Trojan.exe").Select

#### REQUIRE A 0.3 SEC PAUSE #####

Workbooks("TEST.xlsm").Sheets("TrojanG.exe").Select

#### REQUIRE A 0.3 SEC PAUSE #####

Workbooks("TEST.xlsm").Sheets("Trojan.exe").Select

#### REQUIRE A 0.3 SEC PAUSE #####

Workbooks("TEST.xlsm").Sheets("TrojanG.exe").Select
Workbooks("TEST.xlsm").Sheets("Trojan.exe").Select
Workbooks("TEST.xlsm").Sheets("TrojanG.exe").Select
Workbooks("TEST.xlsm").Sheets("Trojan.exe").Select
Workbooks("TEST.xlsm").Sheets("TrojanG.exe").Select
End Sub

At the top i have the following code....
Code:
#If VBA7 Then ' Excel 2010 or later
Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal Milliseconds As LongPtr)
#Else ' Excel 2007 or earlier
Private Declare Sub Sleep Lib "kernel32" (ByVal Milliseconds As Long)
#End If

.... Now this is where im stuck, I know i need to create a loop then call the loop in beetween the change of worksheets but my online copy & paste skills are running low lol

Any suggestions or advice would be appriciated
Thanks
Pancho!
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Forum statistics

Threads
1,214,829
Messages
6,121,826
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top