Oberon70
Board Regular
- Joined
- Jan 21, 2022
- Messages
- 160
- Office Version
- 365
- Platform
- Windows
Hi,
I am hoping to get help as I am new to VBA and I am a bit lost on how to arrange a choice to initiate a specific Sub Procedure.
I have written code with an input box and a start of an It and Else Statement, but I don't know how I can get it to work when there are four groups. This code will be changed, where I obtain a portfolio code from a statement this code will fall into four different groups, which depends on what system the files are on.
I have four systems below are fake Portfolio Codes
WayneRC,WayneT2E,WayneIAE,WayneT15E goes to system 1.
WayneIA,WayneMCIA goes to system 2.
WayneIAG,WayneRCG,WayneT2G,WayneT15G goes to system 3.
Waynei90 goes to system 4
When the code sees any of the Portfolio codes for system one it will run Call System1_Sort
and the same for system 2, system 3 and system 4.
Call System2_Sort
Call System3_Sort
Call System4_Sort
I did try to use a mini sheet, but the only thing on the sheet is a button to run the code.
I am hoping to get help as I am new to VBA and I am a bit lost on how to arrange a choice to initiate a specific Sub Procedure.
I have written code with an input box and a start of an It and Else Statement, but I don't know how I can get it to work when there are four groups. This code will be changed, where I obtain a portfolio code from a statement this code will fall into four different groups, which depends on what system the files are on.
I have four systems below are fake Portfolio Codes
WayneRC,WayneT2E,WayneIAE,WayneT15E goes to system 1.
WayneIA,WayneMCIA goes to system 2.
WayneIAG,WayneRCG,WayneT2G,WayneT15G goes to system 3.
Waynei90 goes to system 4
When the code sees any of the Portfolio codes for system one it will run Call System1_Sort
and the same for system 2, system 3 and system 4.
Call System2_Sort
Call System3_Sort
Call System4_Sort
VBA Code:
Sub Main()
Dim PortfolioCode As Variant
With Application
.Calculation = xlCalculationManual
.ScreenUpdating = False
.EnableEvents = False
.CutCopyMode = False
End With
PortfolioCode = InputBox("Enter the Portfolio Code")
If PortfolioCode = "WayneRC" Or "WayneT2E" Or "WayneT15E" Or "WayneIAE" Then
Call System_1
Else
Call System_2
End If
With Application
.Calculation = xlCalculationAutomatic
.ScreenUpdating = True
.EnableEvents = True
.CutCopyMode = True
End With
End Sub
Sub System_1()
MsgBox "You have chosen System 1"
End Sub
Sub System_2()
MsgBox "You have chosen System 2"
End Sub
Sub System_3()
MsgBox "You have chosen System 3"
End Sub
I did try to use a mini sheet, but the only thing on the sheet is a button to run the code.