Edit input in userform...

KMKfan

Board Regular
Joined
Mar 8, 2004
Messages
106
I need help with my userform.

I have a userform that users can input data for a report. The problem I have is that every time the Input form is called, it is empty. I need the ability to edit input that has already be entered. I want to keep the ability to enter new input onto a blank userform (dialog box) as well as fill the userform based on the information that is currently in the spreadsheet.

Here's my code:

Code:
Sub Edit_EInput_Form()
'Allows use to edit input using dialog box.
    Worksheets("Input").Select
    Dim UW_Combo As Object
    Set UW_Combo = Range("E14").Text
'More code to set the other variables here.
    Input_Form.Show
    End Sub

The above code gives me an 'object required' error.

Code:
Sub Edit_EInput_Form()
'Allows use to edit input using dialog box.
    Worksheets("Input").Select
    Dim UW_Combo As Object
    Set UW_Combo = UW_Combo
    UW_Combo.Text = Range("E14").Text
'More code to set the other variables here.
    Input_Form.Show
    End Sub

gives a 'Object variable or With block variable not set'.

And, finally,

Code:
Sub Edit_EInput_Form()
'Allows use to edit input using dialog box.
    Worksheets("Input").Select
    Dim UW_Combo As ComboBox
    Set UW_Combo.Text = Range("E14").Text
'More code to set the other variables here.
    Input_Form.Show
    End Sub

Gives me an 'Invalid use of property' compile error.

Also, if there is an easier way to accomplish this, let me know.

Right now I have written a "new input" macro (blank userfrom) and am working on the above "edit input" macro. (I realize it's easier to just change a few input on the spreadsheet, but other people in my department have asked to also be able to edit info in the userform.)

Thanks for the help.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
I think I've got it. Userform_Initialize(). Feeling kind of dumb. Is there a way for the userform to initialize a different way based on the calling macro?

ie: if Initialize is called by "Call_EInput", it will initialize one way, and if called by "Edit_EInput" it will initialize another.
 
Upvote 0
This illustrates how it would work with a standard module. It may be a simple example, but hopefully you can apply it how you need. HTH.
Code:
Sub option1()

Call tt(1)

End Sub

Sub option2()

Call tt(2)

End Sub
Sub tt(x As Integer)

Select Case x
Case 1
    MsgBox "Called from option1."
Case 2
    MsgBox "Called from option2."
Case Else
    MsgBox "Different Call."
End Select

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,519
Members
448,968
Latest member
Ajax40

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top