Solved

VBA-

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How does CurrentUser work? 10 37
How to make an ADE file by code? 11 87
Child Form in front 4 47
backup program with robocopy 6 22
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…
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…

810 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