?
Solved

VBA-

Posted on 2004-07-30
7
Medium Priority
?
124 Views
Last Modified: 2010-05-02
I have written a following macro -

For Each Cell In Selection
    Cell = Trim(Cell)
        If IsNumeric(Cell) = False Then
            If Cell <> "" Then
            MsgBox " not numeric value"
            End If
        End If
    Next Cell

But I want to change font colr of that cell which has no numeric value to red
0
Comment
Question by:michaelm702
[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
  • 3
7 Comments
 
LVL 7

Expert Comment

by:manthanein
ID: 11675125
For Each Cell In Selection
    Cell = Trim(Cell)
        If IsNumeric(Cell) = False Then
            If Cell <> "" Then
            MsgBox " not numeric value"
            End If
       else
            Selection.Font.ColorIndex = 3
        End If
    Next Cell

0
 
LVL 7

Expert Comment

by:manthanein
ID: 11675131
wrong post

it should be

For Each Cell In Selection
    Cell = Trim(Cell)
        If IsNumeric(Cell) = False Then
            If Cell <> "" Then
            MsgBox " not numeric value"
            End If
       else
            cell.select
            Selection.Font.ColorIndex = 3
        End If
    Next Cell




0
 

Author Comment

by:michaelm702
ID: 11675278
Wrong - It does not work. In place of MsgBox " not numeric value" I should be able to give red colour to the font of the cell.
0
 
LVL 7

Accepted Solution

by:
manthanein earned 100 total points
ID: 11675818
sorry about that..

For Each Cell In Selection
    Cell = Trim(Cell)
        If IsNumeric(Cell) = False Then
            If Cell <> "" Then
            cell.select
            Selection.Font.ColorIndex = 3
            End If
        End If
    Next Cell
0
 
LVL 7

Expert Comment

by:_agj_
ID: 11676704
i suggest u cud do it other than from code.
use conditional formatting where u can specify the condition Isnumeric for a range...and say wat to do when not satisfied.

this is unless u want to do it from code itself.

u'll find this in format->conditional formatting
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

762 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