Need HELP with writing a Macro! Please!

docops

New Member
Joined
Feb 28, 2021
Messages
3
Office Version
  1. 365
Platform
  1. MacOS
"Column A includes a list of names.
Write a macro that will ask the user to enter a name (the default name is alex), and the macro will return the cell address of the required name. If the name does not exist – A proper message will be shown.
You should consider the list is dynamic and the macro is able to check every list length."
If you can help me with this please let me know
Screen Shot 2021-03-08 at 2.01.23 PM.png
Screen Shot 2021-03-08 at 2.01.30 PM.png
Screen Shot 2021-03-08 at 2.03.08 PM.png
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Try this:

Code:
Sub FindName()
Dim name As String, lr As Long, c As Range
lr = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
name = InputBox("Enter a name")
Set c = Range("A1:A" & lr).Find(name)
If c Is Nothing Then
 MsgBox "The name " + name + " wasn't found."
 Exit Sub
End If
MsgBox "The name " + name + " is in cell " + c.Address()
End Sub
 
Upvote 0
Solution
Thank you so much, had to edit it slightly. It worked.
THank you!!
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,259
Members
449,075
Latest member
staticfluids

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