VB using if statement

Casey

Board Regular
Joined
Feb 18, 2002
Messages
82
Hello,
I was wondering if anyone knows how to use an if statement in this context. If a cell has a numerical value then perform such and such operation i.e. if cell is a number then divide by two and put in another cell, otherwise do nothing.
thanks for any advice you could give
Casey
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Suppose Cell "A1" on "Sheet1" holds the value, suppose cell "B1" on the same sheet is to hold the result, you would use the "if" statement like this:<pre>
With Sheets("Sheet1")
If IsNumeric(.Range("A1").Value) Then
.Range("B1").Value = .Range("A1").Value / 2
End If
End With</pre>
HTH

_________________<font color = green> Mark O'Brien
This message was edited by Mark O'Brien on 2002-05-10 11:35
 
Upvote 0
Thankyou very much I didnt know there is a Isnumeric function.
thanks again
Casey
 
Upvote 0

Forum statistics

Threads
1,213,496
Messages
6,113,993
Members
448,539
Latest member
alex78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top