• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA ActiveX ComboBox code to display today's date in corresponding column

Divad

New Member
I have a list of numbers in column B. I created an ActiveX Combobox consisting of one of all the part numbers listed in column B. When I click on a part number in the Combobox, I would like to have today’s date appear on the same row as the part number in Column G. For example if I select number 3504 in the Combobox which happens to be in B14 and B28, then today’s date is automatically entered into G14 and G28. The code I currently have does not do anything when I click on a value in the ComboBox. I have included the code below. I am VERY new to VBA so I am not really sure what I’m doing.
 

Attachments

  • ComboBox.xlsm
    19.1 KB · Views: 3
'Cause of your bad worksheet design some Excel basics can not be used​
so the question is : why data start in cell B2 rather than in B1 or better in A1 ? No header ? …​
A must see in VBA help : the Range.Find method !​
 
In the real document, the data starts at B7... and I don't really know much about VBA, I only need it to do this one function.. do you think you could provide a sample code or suggestion using the range.find method?
 
According to VBA help - kid level reading - with the help of the Macro Recorder as a VBA beginner starter​
to paste to the Sheet1 worksheet module of your attachment :​
Code:
Private Sub ComboBox1_Change()
           Dim Rf As Range, R&
    With Me.UsedRange.Columns(1)
           Set Rf = .Find(ComboBox1.Value, , xlValues, xlWhole)
        If Not Rf Is Nothing Then
                   R = Rf.Row
            Do
                       Rf(1, 6).Value = Date
                   Set Rf = .FindNext(Rf)
            Loop Until Rf.Row = R
                   Set Rf = Nothing
        End If
    End With
End Sub
Do you like it ? So thanks to click on bottom right Like !​
 
Back
Top