+ Reply to Thread
Results 1 to 9 of 9

Load tekst with combobox

Hybrid View

vds Load tekst with combobox 09-05-2010, 10:42 AM
mikerickson Re: Load tekst with combobox 09-05-2010, 11:36 AM
vds Re: Load tekst with combobox 09-05-2010, 02:55 PM
vds Re: Load tekst with combobox 09-05-2010, 03:08 PM
mikerickson Re: Load tekst with combobox 09-05-2010, 03:11 PM
davesexcel Re: Load tekst with combobox 09-05-2010, 03:20 PM
vds Re: Load tekst with combobox 09-05-2010, 03:32 PM
unley Re: Load tekst with combobox 09-05-2010, 05:21 PM
snb Re: Load tekst with combobox 09-06-2010, 06:57 AM
  1. #1
    Registered User
    Join Date
    08-23-2010
    Location
    Brussel, Beglium
    MS-Off Ver
    Excel 2003
    Posts
    6

    Load tekst with combobox

    Hi,

    I want to load some tekst in a userform.
    In the userform i have a combobox and when i choos 'keuze1' he need to let see the numbers (in the tekstbox from the userform) that are in blue. when i choos 'keuze 2' he must let see the red numbers. when i choos 'keuze 3' he must let see the yellow numbers and 'keuze 4' he must let see the black numbers in the tekstbox from the userform.

    At the moment he only let see the blue numbers because i do not know how to start...

    Can sombody help me start with it?

    regards
    Attached Files Attached Files

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Load tekst with combobox

    The attached has two new named ranges ChannelData and ChannelIndicator, and this code for the userform.
    Private Sub cmd_apply_Click()
        Dim CurrentChart As Chart, Fname As String
        If Not rngindicatedChannel Is Nothing Then
            With rngindicatedChannel
                .Cells(1, 1).Value = Val(Me.TextBox1.Text)
                .Cells(1, 2).Value = Val(Me.TextBox2.Text)
                .Cells(1, 3).Value = Val(Me.TextBox3.Text)
            End With
            On Error Resume Next
            rngChannelIndicator.Value = Me.cbo_channel.Value
            On Error GoTo 0
        End If
    End Sub
    
    Private Sub cbo_channel_Change()
        If Not rngindicatedChannel Is Nothing Then
            With rngindicatedChannel
                Me.TextBox1.Text = CStr(.Cells(1, 1))
                Me.TextBox2.Text = CStr(.Cells(1, 2))
                Me.TextBox3.Text = CStr(.Cells(1, 3))
            End With
        End If
    End Sub
    
    Private Sub cmd_ok_Click()
        'Verwijzing naar update sub
        cmd_apply_Click
        'Form Sluiten
        Unload Me
    End Sub
    
    Private Sub UserForm_Initialize()
        Dim cPart As Range
        Dim cLoc As Range
        
        For Each cPart In ThisWorkbook.Names("ChannelList").RefersToRange
          With Me.cbo_channel
            .AddItem cPart.Value
            '.List(.ListCount - 1, 1) = cPart.Offset(0, 1).Value
          End With
        Next cPart
        
        Me.cbo_channel = CStr(rngChannelIndicator)
    
    End Sub
    
    Function rngChannelIndicator() As Range
        On Error Resume Next
            Set rngChannelIndicator = ThisWorkbook.Names("ChannelIndicator").RefersToRange.Cells(1, 1)
        On Error GoTo 0
    End Function
    
    Function rngindicatedChannel() As Range
        With cbo_channel
        If -1 < .ListIndex Then
            On Error Resume Next
                Set rngindicatedChannel = ThisWorkbook.Names("ChannelData").RefersToRange.Rows(1).Offset(.ListIndex, 0)
            On Error GoTo 0
        End If
        End With
    End Function
    Attached Files Attached Files
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  3. #3
    Registered User
    Join Date
    08-23-2010
    Location
    Brussel, Beglium
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Load tekst with combobox

    Hi

    thanks for your reaction but it is not working?

    regards

  4. #4
    Registered User
    Join Date
    08-23-2010
    Location
    Brussel, Beglium
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Load tekst with combobox

    Hello,

    when i use the excel file that mikerickson posted download i can not load the userform?
    I use excel 2003. can that be the problem?

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Load tekst with combobox

    It works fine on my Excel2004, and it should work on Excel 2003.

  6. #6
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Re: Load tekst with combobox

    Did you close the original workbook? There may be a conflict there.

  7. #7
    Registered User
    Join Date
    08-23-2010
    Location
    Brussel, Beglium
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Load tekst with combobox

    Yes,
    renamed the original, closed it and opend the new from mikerickson.
    but he gives a problem.
    it will be something for tomorrow i gues.
    thanks for your replay's

  8. #8
    Forum Contributor unley's Avatar
    Join Date
    11-27-2008
    Location
    South Australia
    MS-Off Ver
    MS Office 2007
    Posts
    253

    Re: Load tekst with combobox

    mikerickson's workbook works fine on mine too so there must be some conflict on yours vds
    I'm using MS Office 2013

  9. #9
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Load tekst with combobox

    With a slight modification of your worksheet this code suffices:

    Private Sub UserForm_Initialize()
      cbo_channel.List = Sheets("Calibration").Cells(20, 7).CurrentRegion.Value
      cbo_channel.ListIndex = 0
    End Sub
    
    Private Sub cbo_channel_Change()
      For j = 1 To 3
        Me("Textbox" & j).Text = cbo_channel.List(cbo_channel.ListIndex, j)
      Next
    End Sub
    implemented in attachment.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1