Solved

VBA-

Posted on 2004-07-30
7
119 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
  • 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 25 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

791 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