?
Solved

Using VBA to search for cell attributes in Excel

Posted on 2014-04-24
1
Medium Priority
?
340 Views
Last Modified: 2014-04-25
Hi,

I'm just learning VBA for Excel 2010 and am faced with looking for cells in a table which have a certain characteristic.  In this case, a percentage format applied.  Haven't seen an obvious way so far to search for this type of characteristic.

Suggestions?

Thanks!

--Ben
0
Comment
Question by:Ben Conner
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 2000 total points
ID: 40021901
Hi,

pls try

Sub Macro()
Set myRange = ActiveSheet.UsedRange
Application.FindFormat.NumberFormat = "0.00%"

Set Result = myRange.Find(what:="", searchformat:=True)
    If Not Result Is Nothing Then
        strFirstAddress = Result.Address
        Do
            lCount = lCount + 1
            Set Result = myRange.Find(what:="", after:=Result, searchformat:=True)
        Loop While Not Result Is Nothing And Result.Address <> strFirstAddress
        MsgBox lCount & " Found", vbInformation
    Else
        MsgBox "None Found", vbExclamation
    End If
End Sub

Open in new window

Regards
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question