Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 2
Default Is cell content text or numeric-need help with existing code

This will probably be an easy one for someone. I have the following code:

Dim rng1 as Range
Sub test()
Set rng1 = Range("A1")
If rng1 = 1 Then
rng1.Font.Bold = True
Else:
End If
End Sub

So if the content of cell A1 is the number 1, the code will bold the number.

I want to generalize the "if" statement so that if the content of cell A1 is
numeric, (any minus number, 0, or any positive number) the "if" statement
will bold it, but if there is text in the cell, it will not bold it. How do
I change the code to make that happen?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Is cell content text or numeric-need help with existing code

No probs.

Sub test()
Dim rng1 As Range
Set rng1 = Range("A1")
If IsNumeric(rng1) Then
rng1.Font.Bold = True
Else:
End If
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"dan" wrote in message
...
This will probably be an easy one for someone. I have the following code:

Dim rng1 as Range
Sub test()
Set rng1 = Range("A1")
If rng1 = 1 Then
rng1.Font.Bold = True
Else:
End If
End Sub

So if the content of cell A1 is the number 1, the code will bold the

number.

I want to generalize the "if" statement so that if the content of cell A1

is
numeric, (any minus number, 0, or any positive number) the "if" statement
will bold it, but if there is text in the cell, it will not bold it. How

do
I change the code to make that happen?




  #3   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 2
Default Is cell content text or numeric-need help with existing code

Hey Bob - Thanks for your prompt response. It's just what I needed and much
appreciated!

Dan C.

"Bob Phillips" wrote in message
...
No probs.

Sub test()
Dim rng1 As Range
Set rng1 = Range("A1")
If IsNumeric(rng1) Then
rng1.Font.Bold = True
Else:
End If
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"dan" wrote in message
...
This will probably be an easy one for someone. I have the following

code:

Dim rng1 as Range
Sub test()
Set rng1 = Range("A1")
If rng1 = 1 Then
rng1.Font.Bold = True
Else:
End If
End Sub

So if the content of cell A1 is the number 1, the code will bold the

number.

I want to generalize the "if" statement so that if the content of cell

A1
is
numeric, (any minus number, 0, or any positive number) the "if"

statement
will bold it, but if there is text in the cell, it will not bold it.

How
do
I change the code to make that happen?






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Is cell content text or numeric-need help with existing code

Don't forget that Conditional Formatting gives you this flexibility too!

--
Patrick Molloy
Microsoft Excel MVP
---------------------------------
"dan" wrote in message
...
This will probably be an easy one for someone. I have the following code:

Dim rng1 as Range
Sub test()
Set rng1 = Range("A1")
If rng1 = 1 Then
rng1.Font.Bold = True
Else:
End If
End Sub

So if the content of cell A1 is the number 1, the code will bold the

number.

I want to generalize the "if" statement so that if the content of cell A1

is
numeric, (any minus number, 0, or any positive number) the "if" statement
will bold it, but if there is text in the cell, it will not bold it. How

do
I change the code to make that happen?




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dividing existing content into two cells Colin Hayes Excel Discussion (Misc queries) 2 March 10th 11 01:23 AM
Changing the cell format doesn't change existing cell content Kate Excel Discussion (Misc queries) 2 January 14th 10 04:44 PM
How to add the same alpha-numeric value to all the content of a co capxc Excel Discussion (Misc queries) 3 July 17th 08 06:30 PM
Delete content of cell without erasing existing formula? duethckey Excel Discussion (Misc queries) 1 October 22nd 07 06:58 PM
Numeric content in one cell ( implicit formula ) and the result in another one PeDevillers Excel Discussion (Misc queries) 7 March 2nd 05 07:40 AM


All times are GMT +1. The time now is 11:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"