+ Reply to Thread
Results 1 to 2 of 2

Write value to worksheet from combobox value

  1. #1
    Registered User
    Join Date
    10-23-2012
    Location
    Fort Worth, Texas
    MS-Off Ver
    Excel 2003
    Posts
    9

    Write value to worksheet from combobox value

    I am attempting to write a code that will search for the value in combobox then write the textbox value in the next column, and then the next time the same values is found right in next empty column to it.

    this is what I have so far but its not working:

    Private Sub CommandButton2_Click()

    Dim rowcount As Long
    Dim ctl As Control

    ' write data to worksheet
    rowcount = Worksheets("idata").Range("A1").CurrentRegion.Rows.Count
    With Worksheets("idata").Range("a1")
    .Offset(rowcount, 1).Value = Me.TextBox1.Value
    .Offset(rowcount, 2).Value = Me.ComboBox1.Value
    .Offset(rowcount, 3).Value = Me.TextBox18.Value
    .Offset(rowcount, 4).Value = Me.ComboBox2.Value
    .Offset(rowcount, 5).Value = Me.TextBox9.Value
    .Offset(rowcount, 6).Value = Me.TextBox6.Value
    .Offset(rowcount, 7).Value = Me.TextBox12.Value
    .Offset(rowcount, 8).Value = Me.TextBox10.Value
    .Offset(rowcount, 9).Value = Me.TextBox6.Value
    .Offset(rowcount, 10).Value = Me.TextBox13.Value
    .Offset(rowcount, 11).Value = Me.TextBox11.Value
    .Offset(rowcount, 12).Value = Me.TextBox8.Value
    .Offset(rowcount, 13).Value = Me.TextBox14.Value
    .Offset(rowcount, 14).Value = Me.TextBox15.Value
    .Offset(rowcount, 15).Value = Me.TextBox16.Value
    .Offset(rowcount, 16).Value = Me.TextBox17.Value
    .Offset(rowcount, 17).Value = Me.ComboBox3.Value
    .Offset(rowcount, 18).Value = Me.ComboBox4.Value



    With Worksheets("ap2").Activate
    Dim acct1 As String

    Dim FoundRange As Range
    acct1 = ComboBox2.Value

    Set FoundRange = Sheets("ap2").Cells.Find(what:=acct1, LookIn:=xlFormulas, lookat:=xlWhole)
    TextBox17.Text = FoundRange.Value
    TextBox17.Text = FoundRange.Offset(0, 1).Value
    End With
    End With

    End Sub

    HELP ME OBI-WAN KENOBI!

  2. #2
    Registered User
    Join Date
    08-16-2012
    Location
    Florida
    MS-Off Ver
    Excel 2016
    Posts
    33

    Re: Write value to worksheet from combobox value

    Did you try putting a "me" in front of the combobox2.value in:

    Dim FoundRange As Range
    acct1 = ComboBox2.Value


    This is something similar, and works like a champ for me:

    Please Login or Register  to view this content.



    BobR

+ 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