Solved

VBA-

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Opening Remote & Local Data Connection 2 41
Validating VB6 Function 19 50
vb6 connector to mongodb 2 29
using web browser with BING 40 89
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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now