VBA example - Excel 2007: search text in Sheet

VBA code to search text in Sheet

In this VBA example code, you will learn how to search for cells in Excel sheet that contain the information that you are looking for. The text in cells that match with the search criteria will be in red color. For example, you have the following text in cells. How can you do if you want to find text in cells that contain the word "VBA"?

Learn Coding
Excel 2007 tutorial
VBA programming tutorial
VBA array
Excel VBA
VBA loop
Learn VBA
Learn Excel VBA
VBA filtering data
VBA function
Microsoft Excel 2007
Excel sample code
One-dimensional array
While loop
Do while loop
For loop
Excel sheet
Excel cells

To run this example VBA code, you will need one Form, one CommandButton, and one TextBox . You may copy or type the sample text above in to your current worksheet.

VBA for Excel: VBA code to search for text in Excel sheet

VBA code for this example:

Option Explicit

Private Sub CommandButton1_Click()    
Call findText("VBA")

End Sub  

Sub findText(ByVal text As String)    
Dim r As Object
Dim i As Integer
i = 1
While Cells(i, 1) <> ""
Set r = Range("A" & i).Find(text)
If Not r Is Nothing Then
          r.Font.Color = RGB(255, 0, 0)
End If
i = i + 1
End Sub



Enter the text:
seo plugin comment

 seo plugin

Hello Web Admin, I noticed that your On-Page SEO is is missing a few factors, for one you do not use all three H tags in your post, also I notice that you are not using bold or italics properly in your SEO optimization. On-Page SEO means more now than ever since the new Google update: Panda. No longer are backlinks and simply pinging or sending out a RSS feed the key to getting Google PageRank or Alexa Rankings, You now NEED On-Page SEO. So what is good On-Page SEO?First your keyword must appear in the title.Then it must appear in the URL.You have to optimize your keyword and make sure that it has a nice keyword density of 3-5% in your article with relevant LSI (Latent Semantic Indexing). Then you should spread all H1,H2,H3 tags in your article.Your Keyword should appear in your first paragraph and in the last sentence of the page. You should have relevant usage of Bold and italics of your keyword.There should be one internal link to a page on your blog and you should have one image with an alt tag that has your keyword....wait there's even more Now what if i told you there was a simple Wordpress plugin that does all the On-Page SEO, and automatically for you? That's right AUTOMATICALLY, just watch this 4minute video for more information at. <a href="http://www.SEORankingLinks.xyz">Seo Plugin</a>
seo plugin http://www.SEORankingLinks.xyz

Kadr Leyn comment

 Kadr Leyn

I made a template about this topic.
Link : http://adf.ly/1ADwZM


This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.