Save Textbox into Named Range
Hi,
I have a group of textboxes who's values I am trying to save into a named
range. I am also trying to save a value from a listbox into the same named
range. I am unable to get this to save to the worksheet.
What am I missing?
Thanks for your help.
Private Sub cmdSave_Click()
Dim ws As Worksheet
Dim Choice As Long
Dim Msg As String
Set ws = MainPagepg
'add 1 as listbox index begins at 0
Choice = lboChoseTenant.ListIndex + 1
'Check for a selection made
If Me.lboChoseTenant.ListIndex = -1 Then
Msg = "Please make a selection"
MsgBox Msg
Me.lboChoseTenant.SetFocus
Exit Sub
End If
With ws 'save any changes
'save the vacant status
Range("Tenants").Item(Choice, 1).Value = Me.lboVacant.ListIndex.Value
'save Tenants Name
Range("Tenants").Item(Choice, 4).Value = Me.txtTenantName
'Save Primary Unit Number
Range("Tenants").Item(Choice, 2).Value = Me.txtPrimaryUnitNo
'Save Additional Unit Numbers
Range("Tenants").Item(Choice, 4).Value = Me.txtAddUnitNos
'save Days Occupied
Range("Tenants").Item(Choice, 7).Value = Me.txtDaysOccupied
End With
End Sub
|