Sub Check_for_Worksheet()
Dim Sheet As String
‘This sub, along with the following “Make_New_Sheet()” checks for a sheet
named “New Sheet”
‘and if it is not present creates a new sheet named “Test”
‘If “Sheet_Name” is a global
viable it only needs to be declared in this sub and can then be used in the
second called sub
Sheet_Name = "New Sheet"
Sheet = ""
Sheet_Found = False
For Each ws In Worksheets
Sheet = ws.Name
If Sheet = Sheet_Name Then
Sheets(Sheet_Name).Visible = True
Sheet_Found = True
End If
Next ws
If Sheet_Found = False Then
Call Make_New_Sheet
End If
End Sub
Sub Make_New_Sheet()
'Add new worksheet called "Test" with a blue tab
Set NewSheet = Worksheets.Add
Sheet_Name = "Test"
NewSheet.Name = Sheet_Name
ActiveWorkbook.Sheets(NewSheet.Name).Tab.ColorIndex = 8
Sheets(NewSheet.Name).Move After:=Sheets(Worksheets.Count)
End Sub
Sub Macro_Visibility()
‘This sub toggles between hiding and un-hiding a sheet named “Test”
If Sheets("Test").Visible = True Then
Sheets("Test").Visible = False
Else:
Sheets("Test").Visible = True
End If
End Sub
Sub Goto_Macro()
‘This sub will open the Visual Basic editor and take you
to the sub named in the activecell
‘Thus if “Test_Macro” is in the activecell
it will take you to “Sub Test_Macro()” code
On Error GoTo No_Macro_Found
Dim Destination_Macro As String
Destination_Macro = ActiveCell
Application.GoTo Reference:=Destination_Macro
No_Macro_Found:
End Sub
Sub Wait_Time()
‘This sub will run for the “Delay_Time”
value (in seconds) and then stop
‘Good for introducing a delay between events
Delay_Time = 5
ThisHour = Hour(Now())
ThisMinute = Minute(Now())
WaitSeconds = Second(Now()) + Delay_Time
waitTime = TimeSerial(ThisHour, ThisMinute, WaitSeconds)
Application.Wait waitTime
End Sub
Sub About_System()
‘This sub calls the two succeeding subs
‘It returns
whether this is running on a 32 or 64-bit system and the version of OS
Call IsOS32bit
Call app_version
End Sub
Sub IsOS32bit()
Dim OSis32bit As Boolean
OSis32bit = False
If InStr(Application.OperatingSystem, "32-bit") Then
OSis32bit = True
MsgBox " 32 bit operating system", , _
Application.OperatingSystem
Else
MsgBox " Not a 32 bit operating system", , _
Application.OperatingSystem
End If
End Sub
Sub app_version()
Version = Application.Version
MsgBox ("Version " & Version)
End Sub
Sub Workbook_Open()
‘This sub assigns a call to the macro “Select_Task”
whenever the Alt & g keys are pressed simultaneously
‘It is assigned when the workbook is opened
‘shortcut key cannot use a number or special character, such as @ or #.
‘Use the (%) for the Alt Key, Caret (^) to symbol
for Ctrl key, and plus (+) for Shiftkey
Application.OnKey "%{q}", "Select_Task"
End Sub
Application.DisplayStatusBar =
True
Application.StatusBar = "Row
Count...." & Count & _
"Character Count...." & Character_Count & "/" & RowCount