Good morning all,
I am new to VBA, had a single class a few days ago. We have an assignment and I'd like to ask for some help to review and wrap my head around it. Below is the module I started, but obviously needs some help. Any tips on sequence and how to make it work would greatly be appreciated.
Best regards,
Carlos
Assignment Description:
Create a simple Excel workbook and VBA macro in which a user is provided a single button to click. Based on the number they provide in a text box above, a different message box will appear.
I know it's not correct, but from my notes I believe I will use something like the following:
----------------------------------------------------------------------
Sub FiveMessages()
Cells(2, 1).Value
' Retrieve the user sentence and store in variable
Dim Sentence As String
Sentence = Cells(1, 2).Value
MsgBox (Sentence)
' Retrieve the user word numbers and store in variables
Dim num1 As Integer
Dim num2 As Integer
Dim num3 As Integer
Dim num4 As Integer
Dim num5 As Integer
num1 = Cells(1, 1).Value
num2 = Cells(1, 2).Value
num3 = Cells(1, 3).Value
num4 = Cells(1, 4).Value
num5 = Cells(1, 5).Value
MsgBox (num1), ("This is the first option.")
MsgBox (num2), ("This is the second option.")
MsgBox (num3), ("This is the third option.")
MsgBox (num4), ("This is the fourth option.")
MsgBox (num5), ("This is the fifth option.")
End Sub
I am new to VBA, had a single class a few days ago. We have an assignment and I'd like to ask for some help to review and wrap my head around it. Below is the module I started, but obviously needs some help. Any tips on sequence and how to make it work would greatly be appreciated.
Best regards,
Carlos
Assignment Description:
Create a simple Excel workbook and VBA macro in which a user is provided a single button to click. Based on the number they provide in a text box above, a different message box will appear.
I know it's not correct, but from my notes I believe I will use something like the following:
----------------------------------------------------------------------
Sub FiveMessages()
Cells(2, 1).Value
' Retrieve the user sentence and store in variable
Dim Sentence As String
Sentence = Cells(1, 2).Value
MsgBox (Sentence)
' Retrieve the user word numbers and store in variables
Dim num1 As Integer
Dim num2 As Integer
Dim num3 As Integer
Dim num4 As Integer
Dim num5 As Integer
num1 = Cells(1, 1).Value
num2 = Cells(1, 2).Value
num3 = Cells(1, 3).Value
num4 = Cells(1, 4).Value
num5 = Cells(1, 5).Value
MsgBox (num1), ("This is the first option.")
MsgBox (num2), ("This is the second option.")
MsgBox (num3), ("This is the third option.")
MsgBox (num4), ("This is the fourth option.")
MsgBox (num5), ("This is the fifth option.")
End Sub