Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Identifying Cell contents in Excel vba - Text, Date, Value etc

Status
Not open for further replies.

xplo5iv

Technical User
Jan 5, 2005
75
GB
Hi

I have created a macro for use in financial spreadsheets. The macro takes the formulae for each cell in a range and converts it to one rounded to 2dp

e.g. Original Formula "=A6/3" , New formula "=Round(A6/3,2)"

I've used an IF with .HasFormula to make sure it doesn't muck up any text, or already include "Round" in the formula, and all works well.

BUT I'd like to be able to get it to round any numerical values too, without messing up dates or text. (This would be particularly useful if Paste Special...Values is used)

Is their a way of identify the cells correctly in vba?

Thx in Advance

Jonathan

 
errrrrrmmmm

IsNumeric
IsDate

.......

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Thanks Geoff

New it must exist somehow, but I was looking in the Excel library, rather than wider vba.

Doh!
 
some addendum,

if you want to check if the number is an integer (for example) u should FIRST check if it's numeric

if isnumeric() then
if isinteger() then
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top