Solved

VBA-

Posted on 2004-07-30
7
120 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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

756 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