Macro to search and find Data

aneshdas

New Member
Joined
Dec 17, 2013
Messages
15


Friends, I am using the following code to find a NAME in my work sheet and to enter their status. But this macro is not compatible if a duplicate or Similar name exist. Friends can you help me to sort out this. What I need is I need this macro to activate the search NAME Cell and then a VB box with OK & NEXT button has to appear. if the activated NAME is exactly the one I am searching, then I will click the OK button then it should display the "Enter Employee Status" box and as continue in my code, But If I press NEXT, the macro should search the next similar NAME and activate it, This process should continue until I click the OK button. (Same like CTRL+F function with an additional Status entry button)
Friends, Any help will be highly appreciable..

<code style="margin: 0px; padding: 0px; border: 0px; font-family: monospace, sans-serif; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; vertical-align: baseline;">
Code:
[/FONT]</code>[FONT=inherit]Sub[/FONT][FONT=inherit] Button1848_Click[/FONT][FONT=inherit]()[/FONT]</pre>[FONT=inherit]      Application[/FONT][FONT=inherit].[/FONT][FONT=inherit]ScreenUpdating [/FONT][FONT=inherit]=[/FONT][FONT=inherit] [/FONT][FONT=inherit]False[/FONT][FONT=inherit]      [/FONT][FONT=inherit]Dim[/FONT][FONT=inherit] BeginCol [/FONT][FONT=inherit]As[/FONT][FONT=inherit] [/FONT][FONT=inherit]Long[/FONT][FONT=inherit]                  [/FONT][FONT=inherit]Dim[/FONT][FONT=inherit] endCol [/FONT][FONT=inherit]As[/FONT][FONT=inherit] [/FONT][FONT=inherit]Long[/FONT][FONT=inherit]                  [/FONT][FONT=inherit]Dim[/FONT][FONT=inherit] ChkRow [/FONT][FONT=inherit]As[/FONT][FONT=inherit] [/FONT][FONT=inherit]Long[/FONT][FONT=inherit]                  [/FONT][FONT=inherit]Dim[/FONT][FONT=inherit] rng [/FONT][FONT=inherit]As[/FONT][FONT=inherit] Range                  [/FONT][FONT=inherit]Dim[/FONT][FONT=inherit] c [/FONT][FONT=inherit]As[/FONT][FONT=inherit] [/FONT][FONT=inherit]Variant[/FONT][FONT=inherit]                  BeginCol [/FONT][FONT=inherit]=[/FONT][FONT=inherit] [/FONT][FONT=inherit]6[/FONT][FONT=inherit]                  endCol [/FONT][FONT=inherit]=[/FONT][FONT=inherit] [/FONT][FONT=inherit]370[/FONT][FONT=inherit]                  ChkRow [/FONT][FONT=inherit]=[/FONT][FONT=inherit] [/FONT][FONT=inherit]7[/FONT][FONT=inherit]                  [/FONT][FONT=inherit]For[/FONT][FONT=inherit] Colcnt [/FONT][FONT=inherit]=[/FONT][FONT=inherit] BeginCol [/FONT][FONT=inherit]To[/FONT][FONT=inherit] endCol        [/FONT][FONT=inherit]If[/FONT][FONT=inherit] Sheets[/FONT][FONT=inherit]([/FONT][FONT=inherit]"Sheet1"[/FONT][FONT=inherit]).[/FONT][FONT=inherit]Cells[/FONT][FONT=inherit]([/FONT][FONT=inherit]ChkRow[/FONT][FONT=inherit],[/FONT][FONT=inherit] Colcnt[/FONT][FONT=inherit]).[/FONT][FONT=inherit]Value [/FONT][FONT=inherit]=[/FONT][FONT=inherit] [/FONT][FONT=inherit]Date[/FONT][FONT=inherit] [/FONT][FONT=inherit]Then[/FONT][FONT=inherit]        Name [/FONT][FONT=inherit]=[/FONT][FONT=inherit] InputBox[/FONT][FONT=inherit]([/FONT][FONT=inherit]"Enter Employee name"[/FONT][FONT=inherit])[/FONT][FONT=inherit]        Cells[/FONT][FONT=inherit].[/FONT][FONT=inherit]Find[/FONT][FONT=inherit]([/FONT][FONT=inherit]What[/FONT][FONT=inherit]:=[/FONT][FONT=inherit]Name[/FONT][FONT=inherit],[/FONT][FONT=inherit] After[/FONT][FONT=inherit]:=[/FONT][FONT=inherit]ActiveCell[/FONT][FONT=inherit],[/FONT][FONT=inherit] LookIn[/FONT][FONT=inherit]:=[/FONT][FONT=inherit]xlFormulas[/FONT][FONT=inherit],[/FONT][FONT=inherit] LookAt[/FONT][FONT=inherit]:=[/FONT][FONT=inherit] _        xlPart[/FONT][FONT=inherit],[/FONT][FONT=inherit] SearchOrder[/FONT][FONT=inherit]:=[/FONT][FONT=inherit]xlByRows[/FONT][FONT=inherit],[/FONT][FONT=inherit] SearchDirection[/FONT][FONT=inherit]:=[/FONT][FONT=inherit]xlNext[/FONT][FONT=inherit],[/FONT][FONT=inherit] MatchCase[/FONT][FONT=inherit]:=[/FONT][FONT=inherit]False[/FONT][FONT=inherit] _        [/FONT][FONT=inherit],[/FONT][FONT=inherit] SearchFormat[/FONT][FONT=inherit]:=[/FONT][FONT=inherit]False[/FONT][FONT=inherit]).[/FONT][FONT=inherit]Activate       ActiveCell[/FONT][FONT=inherit].[/FONT][FONT=inherit]Select[/FONT][FONT=inherit]        [/FONT][FONT=inherit]Set[/FONT][FONT=inherit] rng [/FONT][FONT=inherit]=[/FONT][FONT=inherit] Sheets[/FONT][FONT=inherit]([/FONT][FONT=inherit]"Sheet1"[/FONT][FONT=inherit]).[/FONT][FONT=inherit]Cells[/FONT][FONT=inherit]([/FONT][FONT=inherit]ChkRow[/FONT][FONT=inherit],[/FONT][FONT=inherit] Colcnt[/FONT][FONT=inherit]).[/FONT][FONT=inherit]Rows[/FONT][FONT=inherit]([/FONT][FONT=inherit]"2:500"[/FONT][FONT=inherit])[/FONT][FONT=inherit]                        [/FONT][FONT=inherit]For[/FONT][FONT=inherit] [/FONT][FONT=inherit]Each[/FONT][FONT=inherit] c [/FONT][FONT=inherit]In[/FONT][FONT=inherit] rng                            [/FONT][FONT=inherit]If[/FONT][FONT=inherit] Sheets[/FONT][FONT=inherit]([/FONT][FONT=inherit]"Sheet1"[/FONT][FONT=inherit]).[/FONT][FONT=inherit]Cells[/FONT][FONT=inherit]([/FONT][FONT=inherit]c[/FONT][FONT=inherit].[/FONT][FONT=inherit]Row[/FONT][FONT=inherit],[/FONT][FONT=inherit] [/FONT][FONT=inherit]2[/FONT][FONT=inherit]).[/FONT][FONT=inherit]Value [/FONT][FONT=inherit]=[/FONT][FONT=inherit] ActiveCell [/FONT][FONT=inherit]Then[/FONT][FONT=inherit]                            [/FONT][FONT=inherit]If[/FONT][FONT=inherit] c[/FONT][FONT=inherit].[/FONT][FONT=inherit]Value [/FONT][FONT=inherit]=[/FONT][FONT=inherit] [/FONT][FONT=inherit]""[/FONT][FONT=inherit] [/FONT][FONT=inherit]Then[/FONT][FONT=inherit]                    Status [/FONT][FONT=inherit]=[/FONT][FONT=inherit] InputBox[/FONT][FONT=inherit]([/FONT][FONT=inherit]"Enter Employee Status"[/FONT][FONT=inherit])[/FONT][FONT=inherit]                              c[/FONT][FONT=inherit].[/FONT][FONT=inherit]Value [/FONT][FONT=inherit]=[/FONT][FONT=inherit] Status                                  [/FONT][FONT=inherit]End[/FONT][FONT=inherit] [/FONT][FONT=inherit]If[/FONT][FONT=inherit]                              [/FONT][FONT=inherit]End[/FONT][FONT=inherit] [/FONT][FONT=inherit]If[/FONT][FONT=inherit]                         [/FONT][FONT=inherit]Next[/FONT][FONT=inherit] c                      [/FONT][FONT=inherit]Else[/FONT][FONT=inherit]                         [/FONT][FONT=inherit]'MsgBox "No Employee in this Name"[/FONT][FONT=inherit]                   [/FONT][FONT=inherit]End[/FONT][FONT=inherit] [/FONT][FONT=inherit]If[/FONT][FONT=inherit]                  [/FONT][FONT=inherit]Next[/FONT][FONT=inherit] Colcnt    Application[/FONT][FONT=inherit].[/FONT][FONT=inherit]ScreenUpdating [/FONT][FONT=inherit]=[/FONT][FONT=inherit] [/FONT][FONT=inherit]True[/FONT][FONT=inherit]    ActiveWorkbook[/FONT][FONT=inherit].[/FONT][FONT=inherit]Save    [/FONT][FONT=inherit]End[/FONT][FONT=inherit] [/FONT][FONT=inherit]Sub[/FONT][FONT=inherit]
[/FONT]

<code style="margin: 0px; padding: 0px; border: 0px; font-family: monospace, sans-serif; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; vertical-align: baseline;">[FONT=inherit]
</code></pre>
 
Last edited:

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,214,641
Messages
6,120,685
Members
448,978
Latest member
rrauni

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