Write a value in certain column if the payroll number is found - Excel VBA

CakzPrimz

Board Regular
Joined
Oct 6, 2017
Messages
57
Hi,

I have a combobox1 to input or call the list of employee's ID number. What I need is:
If I select/type one of the ID number of the list and ID number was found and I hit OK button then a word "resign" should add at column Q (column [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=1]#1 7[/URL] ), right exactly at the row where the employee's ID were found. The ID number is in column A (column #1 ). The name of the sheets is "employ".

Thanks in advance.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
As you can see I have written a separate sub for this, you can pick from it what you need essencially I have allocated the value of the combobox to a variable and then looped to look for it.

Someone else may be able to do this without looping,

This will not work as a separate sub.

Code:
Sub FillDataIn()


Dim a As Long
Dim i As Long
Dim LastRow As Long


a = ComboBox.Value


LastRow = Worksheets("Employ").Cells(Rows.Count, 1).End(xlUp).Row


    For i = 1 To LastRow
    
    If Worksheets("Employ").Cells(i, 1) = a Then Cells(i, 17).Value = "resign"


    Next i


End Sub
 
Upvote 0
Dear Dryver14,

Thanks for your quick response. It works well and I am very happy to apply the code in mine. Thanks so much.
I really appreciate it.

Problem solved !!!

Best regards,
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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