I would like to use a command button to submit data input into a userform to a worksheet depending on what option is selected from a listbox. I have two worksheets one named "Linux" the other "Microsoft". When an OS is selected related to one or the other the data input in the userform will be inserted into the appropriate worksheet upon clicking on command button.


Currently used code:
Private Sub cmdAddNewHostMS_Click()

Dim lrow As Long
Dim wb As Workbook
Dim wsl As Worksheet
Dim wsm As Worksheet
Set wb = ThisWorkbook
Set wsm = Worksheets("Microsoft")
Set wsl = Worksheets("Linux")

'find empty row on Microsoft worksheet
lrow = wsm.Range("A1").CurrentRegion.Rows.Count
With wsm.Range("A1")

'insert data into worksheet
.Offset(lrow, 2) = Me.txtServerFunction.Value
.Offset(lrow, 14) = Me.txtDataCenter.Value
.Offset(lrow, 5) = Me.lstOperatingSystem.Value
.Offset(lrow, 11) = Me.txtAppsInstalled.Value
.Offset(lrow, 6) = Me.txtVirtualRam.Value * 1.5
.Offset(lrow, 19) = Me.txtVirtualCPU.Value
.Offset(lrow, 20) = Me.txtVirtualRam.Value
.Offset(lrow, 23) = Me.txtOSVolume.Value
.Offset(lrow, 27) = Me.txtBronzeTier.Value
.Offset(lrow, 31) = Me.txtSilverTier.Value
.Offset(lrow, 35) = Me.txtLogsTier.Value
.Offset(lrow, 39) = Me.txtGoldTier.Value
.Offset(lrow, 21) = Format(CDbl(txtOSVolume.Value) + CDbl(txtBronzeTier.Value) + CDbl(txtSilverTier.Value) + CDbl(txtLogsTier.Value) + CDbl(txtGoldTier.Value))

End With

Unload Me
frmSrvInfo.Show

End Sub