Hi
I have recently found the very helpful =isFunction UDF
at http://www.ozgrid.com/VBA/ExcelIsFormula.htm
Function IsFormula(Check_Cell As Range)
IsFormula = Check_Cell.HasFormula
End Function
which I dont understand but can use nicely to do very useful conditional formatting.
I have done 3 hours of looking (F1 help, search ozgrid / search google etc) without getting very far, enough to think that it ought to be possible to create other types of cellchecking.
Is it possible to create other 'cellchecking' functions? what are they? can I find a list somewhere?
specifically can I create a function which checks if a cell's contents are an integer (rather than a decimal)?
Thanks...
Test if cell contains integer
-
-
-
-
Re: Test if cell contains integer
Mark,
Please try not to assume knowledge of the answer when entering a thread title. Please use search friendly terms that as accurately as possible describe your question. I have revised your title for you this time. Thank you.
You do not need VBA for this. Can easily be done with Excel.
=IF(INT(A1)=A1, TRUE, FALSE)
Will tell you if A1 contains an integer. -
Re: Test if cell contains integer
Thanks Rob & Cytop, for the fast answers
I will give these a try.
However as a more general issue ... would it be possible to create other tests such as:-
Function IsInt(Check_Cell As Range)
IsFormula = Check_Cell.HasInteger
End FunctionWhat I don't know about is, what options can I use with Check_Cell.Has??? to check for other stuff.
does this make sense?
Thanks -
Re: Test if cell contains integer
Check_Cell is a reference to a range. A ranges has various properties and methods and you can find them listed at the bottom of this page: http://msdn.microsoft.com/en-us/library/…office.11).aspx
J -
-
Re: Test if cell contains integer
Hello cytop,
Thanks again for such a fast reply.
Using your previous reply I have now achieved the conditional formatting which I was aiming for:-
Starting with cell A295 if I add conditional formating rule :-
Rule: =INT($A295)<>$A295
Applies to: =$A$295:$B$312Then I can copy the format to range A295:b312
meaning that the formatting for each row is dependent on the contents of column A for that row (ie is it an integer?)**Thanks for my solution.**
As for Check_cell, I have had a look at the link and the information is well beyond my knowledge level (sad smile) However I plan to experiment with the methods & properties later on, so thanks for that referal also.
Regards
Mark -
Re: Test if cell contains integer
Just remember properties and methods in this context are programming concepts.
A range (which can be a single cell or a collection of cells) has various attributes (or properties) such as font, colour and other 'physical attributes'.
It also has 'Methods' which are do-able things.. Activate for example, make the range the current selection in Excel. 'BorderAround' draws a border around it. Cut and Copy are other methods.
Perhaps that might make the distinction a little clearer.
J -
Re: Test if cell contains integer
A lot of the cell checking that you seem interested in can be achieved without VBA by using the GET.CELL macro command, that is not accessible through worksheet cells, but is via Names.
-
Re: Test if cell contains integer
Nice link Mike. I vaguely knew about GET.CELL but had never used it.
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!