excel vba find method
Microsoft Office TrainingThe UK's Number 1 for Microsoft Office Training Sitemap add this page to your favourites/bookmarksBookmark page
 
view a printable version of this pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Excel VBA Find Method (CTRL + F)

Excel VBA Find Method (CTRL + F)

resolvedResolved · High Priority · Version 2003

replyReplyWed 19 May 2010, 16:38Delegate Brian said...

Excel VBA Find Method (CTRL + F)

Hello,

After my Excel VBA course I have taken to writing code very well but one area I am having extreme trouble with is FIND functionality.

I wish to have a subroutine for finding a value within a Range (B:B) in a spreadsheet. The value would come from a text box in a user form so assume that this will be a variable.

If the item is matched then it is to show a message box and end.

If there is no match then it needs to go onto a seperate subroutine.

Any help would be much appreciated.

Thanks

Brian

For upcoming training course dates see: Pricing & availability

replyReplyFri 21 May 2010, 09:35 Edited on Fri 21 May 2010, 09:35Trainer Stephen said...

RE: Excel VBA Find Method (CTRL + F)

Hi Brian

Thanks for your question

It seems that the find tool is not supported in VBA. However it is easy to do what you say with a simple looping and decision structure. The following seems to work well

Sub Find()


Dim MyRange As Range
Dim i As Integer

Set MyRange = Columns("A:A")

For i = 1 To MyRange.CurrentRegion.Rows.Count

If MyRange.Cells(i, 1).Value = "Peter" Then

MsgBox "Found it"
Exit Sub


End If

Next i

Call Subroutine

End Sub


This simply cycles through each cell in the column looking for a value. If it is found it displays a message box and ends the routine. If it gets to the end with no result it simply calls the sub procedure. I have entered the value as a literal, but this is easily replaced with a variable holding the text box's value.

Hope this helps

Regards

Stephen

 

 

Please browse our web site to find out more about
excel software training and other Microsoft training courses.

Excel tip:

Copying Formulae Quickly

There is a quicker way of copying a formula down a column.

Just point and double click on the black autofill handle in the right hand corner of a cell.

This will work providing you have some data in the column to the left of the column.

Sandy

View all Excel hints and tips

forum postHow do I play a video files from my presentation?

» Forum post: Multimedia - adding video files


Rate this page:
2.2/5 (213 votes cast)
Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses
Microsoft Certified Partner
Security Seal verified by visa, mastercard securecard

Mini sitemap. These are the main areas of our web site. Full sitemap.

Management training

Professional Skills courses
Project Management Course London
Project Management Courses London
Project Management Training London
Project Management Training
Project Seminar
Project Seminars
Time Management Course London
Time Management London
Time Management Courses London
Time Management Training London
Introduction to Finance course
Assertiveness Skills course
Effective Communications Skills training
Presentation Skills London

Training Formats

Public scheduled courses
On-site training
Closed company courses

Consultancy
Application Development

Blogs

Excel Training
MS Project Training
Microsoft Training Blog

Version differences

Office 2010 vs 2007
MS Project version differences

Training Information

London Computer Training
Computer Training London
Docklands Training Courses
Docklands Training London

Training venues London
Client list
FAQ
Pricing and availability
Course details / Syllabus

Training Articles
Training Information

Microsoft training

Microsoft Office training
& IT Applications

Microsoft Project training
Microsoft Outlook training
Microsoft Powerpoint training
Microsoft Word training
MS Project courses
MS Project training
Outlook courses
PowerPoint courses
PowerPoint training
VBA courses
Word courses
Microsoft.training
(more...)

Excel Training

Excel courses
Excel Training Courses Medway
Autonumber in Excel
Microsoft Excel training
Basic Excel Courses
Basic Excel Course
Basic Excel Training

Interested in MS Access training?

Access courses
Microsoft Access training
Microsoft access courses
Microsoft training access course
Microsoft+access+training
Access courses in london

Training provider

Training providers
IT training companies
IT training providers
Management Training providers
Management Training provider

Event history, feedback results
Events in 2012 · 2011 · 2010 · More

See also

Crystal Reports training