letters in a number

jigglypuff

New Member
Joined
Mar 28, 2013
Messages
25
If Target.Row >= 5 Then
If Cells(Target.Row, 5).Value >= 1 Then Cells(Target.Row, 5).Interior.Color = vbGreen
If Cells(Target.Row, 5).Value < 1 Or Cells(Target.Row, 5).Value = "" Then Cells(Target.Row, 5).Interior.Color = xlNone
End If


I am having problems with this code, when I set a number with letter, e.g.: '899gg', a error appears on the screen. Any ideas of what could have causing it? I think I have to set another if sentence saying that if a number has letters then (target.roll, 5).value = "" but have no idea how to do so...
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Can you tell us what the error says?

As far as I can tell that code should have no problems and the cell could contain any value.
 
Upvote 0
as soon as I set any number with letters (or just letters) this error appears: run-time error '13': type mismatch
 
Upvote 0
Works for me, I can only produce that error by entering an error value like #N/A or #VALUE!

But entering Blanks Numbers or Mixed values, it works fine.
 
Upvote 0
Try this:
Code:
IsNumeric( expression )

Another thought is to check the types of the cells being looked at to see if there is a conversion needed (CStr).
 
Last edited:
Upvote 0
'celulas verdes'
If Target.Row >= 5 And IsNumeric(Cells(Target.Row, 3)) Then
If Cells(Target.Row, 5).Value >= 1 Then Cells(Target.Row, 5).Interior.Color = vbGreen
If Cells(Target.Row, 5).Value < 1 Or Cells(Target.Row, 5).Value = "" Then Cells(Target.Row, 5).Interior.Color = xlNone
End If

If Not IsNumeric(Cells(Target.Row, 3)) Then Cells(Target.Row, 5).Interior.Color = xlNone



I used it to solve the problem thanks everybody for the ideas :)
 
Upvote 0

Forum statistics

Threads
1,203,101
Messages
6,053,530
Members
444,670
Latest member
laurenmjones1111

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top