Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Save Textbox into Named Range
Hi
Never mind. I think I've got it. 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
macro to save named range as text | Excel Programming | |||
inserting a named range into new cells based on a named cell | Excel Discussion (Misc queries) | |||
Determining whether a named textbox on a chart exists | Excel Programming | |||
If any cell in named range = 8 then shade named range | Excel Programming | |||
How do I set the value of a textbox on a userform to the value in a named cell? | Excel Programming |