In Part 2 we look at putting the code behind our UserForm to give it some use.
Code for the Submit button:
Private Sub submitBTN_Click()
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
Dim choice As Integer
Dim newRow As Long
newRow = Application.WorksheetFunction.CountA(ws.Range("B:B")) + 2
If depositOPT = False And withdrawOPT = False Then
MsgBox "Select an option: Deposit or Withdraw"
Exit Sub
End If
If depositOPT = True Then
choice = 3
ws.Cells(newRow, 2).Value = Me.bookieTXT.Value
ws.Cells(newRow, choice).Value = Me.amountTXT.Value
Me.amountTXT.Value = ""
Me.bookieTXT.Value = ""
End If
If withdrawOPT = True Then
choice = 4
ws.Cells(newRow, 2).Value = Me.bookieTXT.Value
ws.Cells(newRow, choice).Value = Me.amountTXT.Value
Me.amountTXT.Value = ""
Me.bookieTXT.Value = ""
End If
End Sub
If you're reading this far, I've added some more lines of code to clear the text boxes and the option buttons.
Смотрите видео Excel VBA UserForm Programming Part 2 онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал Tutorial Spot 12 Март 2016. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 272 раз и оно понравилось 4 посетителям.