Results 1 to 4 of 4
  1. #1
    Star Lounger
    Join Date
    Nov 2005
    Location
    London, Gtr London, United Kingdom
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Populate Word VBA Userform with Excel Value (VBA/Word/2000)

    Hi.

    I'm trying to have a value from a specified sheet/cell in excel appear in a userform textbox depending on the value of a dropdown list the user has already selected... if that make sense.... but i'm kindoff stuck!!

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Populate Word VBA Userform with Excel Value (VBA/Word/2000)

    Can you be more specific? What kind of value does the user select from the combo box and how does this determine the cell to be used?

  3. #3
    Star Lounger
    Join Date
    Nov 2005
    Location
    London, Gtr London, United Kingdom
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Populate Word VBA Userform with Excel Value (VBA/Word/2000)

    Hi.

    It a prepopulated dropdown that the user selects from. i.e. Monday, Tuesday, Wednesday. Then if Wednesday is selected, a greyed out textbox on the form shows the value of A$1$ from the Tuesday wooksheet of a specified worksheet. Likewise, if Monday is selected, then A$1$ from the Monday worksheet.

    this is my feeble attempt so far!!

    Private Sub TextBox1_Change()
    Dim myWB As Excel.Workbook
    Set myWB = GetObject("j&PThom.xls")
    With Me.myDropdown_Type
    If cboClient_Type = "Monday" Then
    TextBox1 = myWB.Worksheets("Monday").Range("ebkMonday") ' i used named cells in excel.
    End If
    End With

    End Sub

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Populate Word VBA Userform with Excel Value (VBA/Word/2000)

    What is myDropDown_Type and why do you have a With ... End With for it if you don't do anything with it?
    You wouldn't use the TextBox1_Change event - TextBox1 is the text box you want to fill. From your code, I'd guess that you should need to use the After Update event of cboClient_Type:

    Private Sub cboClient_Type_AfterUpdate()
    Dim myWB As Excel.Workbook
    Set myWB = GetObject("j&PThom.xls")
    Me.TextBox1 = myWB.Worksheets(Me.cboClient_Type).Range("ebk" & Me.cboClient_Type)
    End Sub

    Don't forget to close the workbook when you're done with the userform.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •