Hi,
I have a question about named ranges when used in Userform routines. I have a number of single worksheet cells as named ranges which are updated by the Userform. I want the Userform to open with the current values in the Worksheet in case it is only one or two values that need to be changed by the user. When I refer to the cells by their range address the code works, when I refer to the cells by their named range the value in the worksheet isn't passed to the Userform?
Here is the code for the form:
Private Sub Closebutton_Click()
Unload UserForm1
End Sub
Private Sub OKbutton_Click()
Sheets("home").Activate
Sheets("home").Range("F16") = tbDateOfBirth
If Optionmale = True Then Sheets("home").Range("F18") = "male"
If Optionfemale = True Then Sheets("home").Range("F18") = "female"
Sheets("home").Range("F15") = tbDateOfInjury
Sheets("home").Range("F17") = tbDateofTrial
Sheets("home").Range("F19") = tbRetirementAge
End Sub
Private Sub SpinButton1_Change()
tbRetirementAge.Value = SpinButton1.Value
End Sub
Private Sub tbRetirementAge_Change()
NewVal = val(tbRetirementAge.Value)
If NewVal >= SpinButton1.Min And _
NewVal <= SpinButton1.Max Then _
SpinButton1.Value = NewVal
End Sub
Private Sub UserForm_Initialize()
tbDateOfInjury = Sheets("home").Range("F15")
tbDateOfBirth.Value = Sheets("home").Range("F16")
tbDateofTrial.Value = Sheets("home").Range("F17")
tbRetirementAge.Value = Sheets("home").Range("F19")
End Sub
Something like tbDateofInjury = mynamedrange whilst not giving me an error doesn't pass the value. I've tried in the immediate window and simply get True which is confusing me even more.
Bookmarks