Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA test for Cell Format type

Status
Not open for further replies.

pcdaveh

Technical User
Sep 26, 2000
213
US
I've created some code that is walking down Column A of my spread sheet and I want to test to see if a certain text condition is met. That condition is a specific number format which is "##-####.#" I'm using a select case statement. What should my Cases be?

Data in column A has "", or is null, Dates, regular text, Numbers and "##-####.#" I'm only concerned with finding "##-####.#"
 
It will be the numberformat property of the Cell

so select Case ActiveCell.numberformat

 
Private Sub FormatTest()
Worksheets("Sheet1").Cells(1, 1).Select
With Selection
If .NumberFormat = "##-####.#" Then
MsgBox "Got It"
Else
End If
End With
End Sub
 
Databaseguy:

I modified your code to:
sub findit()
Dim ls_ColumnA as Integer
Do
Range("A" & ls_ColumnA).Select
With Selection
If .NumberFormat = "##-####.#" Then
MsgBox "Got It"
Else
End If
End With
ls_ColumnA = ls_ColumnA + 1
Loop
end sub

'it still doesn't find it. Here is an actual value to put into the worksheet. "14-2801.9" of course w/o the quotes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top