View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Karen53 Karen53 is offline
external usenet poster
 
Posts: 333
Default Save Textbox into Named Range

Hi,

I think the problem here is not that this isn't saving but that if they
overtype the information displayed in the textbox to change it it's not
saving that change. Is there a way to update the textbox for the user's
change?

Thanks,



"Karen53" wrote:

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