How to use VBA to search for a value on a Worksheet



How to use VBA to search for a value on a Worksheet. Use VBA to find a value on another sheet. How to find a value and retrieve a number from another cell on that row. Allow me teach you the skills in Excel that you need for business

Let me teach you the VBA that I have learn in my five years of consulting

Become an Affiliate and earn 25% on Course Sales

Sub findsomething()
Dim rng As Range
Dim account As String
Dim rownumber As Long

account = Sheet1.Cells(2, 1)

Set rng = Sheet2.Columns(“A:A”).Find(What:=account, _
LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
rownumber = rng.Row
Sheet1.Cells(2, 2).Value = Sheet2.Cells(rownumber, 3).Value

End Sub

For more help visit my website or email me at easyexcelanswers@gmail.com.

Contact me regarding customizing this template for your needs.

Excel one-on-one on-line training available. Email me to arrange.

I am able to provide online help on your computer at a reasonable rate.

Check out my next one-hour Excel Webinar

I use a Blue condensor Microphone to record my videos, here is the link

Check out Crowdcast for creating your webinars

If you need to buy Office 2019 follow

I use Tube Buddy to help promote my videos
Check them out

Follow me on Facebook

Follow me on twitter
easyexcelanswers

IG @barbhendersonconsulting

You can help and generate a translation to you own language

*this description may contain affiliate links. When you click them, I may receive a small commission at no extra cost to you. I only recommend products and services that I’ve used or have experience with.

Watch more new videos about Excel Office | Synthesized by Mindovermetal English

Rate this post

Bài viết liên quan

Theo dõi
Thông báo của
guest
9 Comments
Cũ nhất
Mới nhất Được bỏ phiếu nhiều nhất
Phản hồi nội tuyến
Xem tất cả bình luận
Barb Henderson

Thank so much for watching my video. Please note, I am not allowed to include square brackets the description of the video, so that if you copy the code from the description, I have replaced >, <>, and < symbols with text.

Before using the code check for these instances.

John G

Thanks in a million. Great content. Awesome. Grade: A++💥

Pro Sight

HI
CAN YOU HELP PLEASE, I NEED TO BRING DATA FROM MULTIPLE SHEETS INSTEAD OF SHEET 2,
THANK YOU

Meme La'chelle

Hi, how do I know where the row# was returned to? I've tried to use the same code to get account 130033 qty 39.31, but I keep getting 1.57 on that. Any time I try to change code I get error codes. Any help or more examples?

Meme La'chelle

Hi, I'm new to VBA and I've been using your tutorial for practice. I keep getting a "run-time error 91" on "rownumber = Rng.row". Where does it reference cells C4 in the code?

Tanner Tucker

Your videos are excellent. Do you know of a way to loop through an entire range of cells and compare the contents of each cell in that range to the contents of another range of cells. If a match is found, then do something (e.g. copy matched cell context to another cell)? Thank you.

Kim Paarup

Dear BarbMaybe you have an idea for me. I have two sheets and need in range D4:BA9 to compare the cells one by one. If the Cell matches in both color and text, the cell shall be cleared in Sheet 1.Hope you can help 🙂

Jermaine Lawrence

Thanks Barb, your simple video help solve a problem I've been working through. I'm only a beginner in VBA. A lot of other videos were a little too complicated for me.

Mohamed Chakroun

Thanks barb
In what case is it this code interesting ?