ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Please help me with an If statement (https://www.excelbanter.com/excel-discussion-misc-queries/122402-please-help-me-if-statement.html)

keri

Please help me with an If statement
 
I am wanting to an if statement that evaluates whether the 1st cell in
a selected column is an integer. If it is I want to do nothing, if it
isn't i want to insert a value in the cell to the left. Then I would
like to move on to the next cell in the coloumn and evaluate as above.

The only problem may be that when the cell is not an integer it will be
either an;

integer then a space then a letter
or
and integer then a letter (no space)

Thanks in advance.


Don Guillett

Please help me with an If statement
 

Sub ifallnum()
For Each c In Range("f2:f22")
If Len(c) 0 And IsNumeric(c) Then c.Offset(, -1) = 33
Next
End Sub

Don Guillett
SalesAid Software

"keri" wrote in message
oups.com...
I am wanting to an if statement that evaluates whether the 1st cell in
a selected column is an integer. If it is I want to do nothing, if it
isn't i want to insert a value in the cell to the left. Then I would
like to move on to the next cell in the coloumn and evaluate as above.

The only problem may be that when the cell is not an integer it will be
either an;

integer then a space then a letter
or
and integer then a letter (no space)

Thanks in advance.




David Biddulph

Please help me with an If statement
 
If your selected column is B, then in A1 insert the formula
=IF(ISNUMBER(B1),IF(B1=INT(B1),"","insert value"),"insert value")
Replace "insert value" by whatever you want writing into that cell.
Copy down.
--
David Biddulph

"keri" wrote in message
oups.com...
I am wanting to an if statement that evaluates whether the 1st cell in
a selected column is an integer. If it is I want to do nothing, if it
isn't i want to insert a value in the cell to the left. Then I would
like to move on to the next cell in the coloumn and evaluate as above.

The only problem may be that when the cell is not an integer it will be
either an;

integer then a space then a letter
or
and integer then a letter (no space)

Thanks in advance.




keri

Please help me with an If statement
 

Don Guillett wrote:
Sub ifallnum()
For Each c In Range("f2:f22")
If Len(c) 0 And IsNumeric(c) Then c.Offset(, -1) = 33
Next



Thanks. I'm guessing (with my small knowledge) this is supposed to put
33 into the column to the right of the selected cell if it IS an
integer. Is this correct? It's not working so far but i'll figure that
out, problem is I need to do it if it is NOT an integer. Can i do a "is
not"?

Oh and what is len?


Don Guillett

Please help me with an If statement
 
For NOT a number just insert NOT in front of isnumeric. Your original
request was for the column to the LEFT. If you want it to the right
change -1 to 1. Also, I did this for a range of cells in col F. If you want
for only one cell just change to if activecell, etc

Len may be looked up in the vba help index

--
Don Guillett
SalesAid Software

"keri" wrote in message
ups.com...

Don Guillett wrote:
Sub ifallnum()
For Each c In Range("f2:f22")
If Len(c) 0 And IsNumeric(c) Then c.Offset(, -1) = 33
Next



Thanks. I'm guessing (with my small knowledge) this is supposed to put
33 into the column to the right of the selected cell if it IS an
integer. Is this correct? It's not working so far but i'll figure that
out, problem is I need to do it if it is NOT an integer. Can i do a "is
not"?

Oh and what is len?




keri

Please help me with an If statement
 
Thank you.

Don Guillett wrote:
For NOT a number just insert NOT in front of isnumeric. Your original
request was for the column to the LEFT. If you want it to the right
change -1 to 1. Also, I did this for a range of cells in col F. If you want
for only one cell just change to if activecell, etc

Len may be looked up in the vba help index

--
Don Guillett
SalesAid Software

"keri" wrote in message
ups.com...

Don Guillett wrote:
Sub ifallnum()
For Each c In Range("f2:f22")
If Len(c) 0 And IsNumeric(c) Then c.Offset(, -1) = 33
Next



Thanks. I'm guessing (with my small knowledge) this is supposed to put
33 into the column to the right of the selected cell if it IS an
integer. Is this correct? It's not working so far but i'll figure that
out, problem is I need to do it if it is NOT an integer. Can i do a "is
not"?

Oh and what is len?



Don Guillett

Please help me with an If statement
 
Glad to help

--
Don Guillett
SalesAid Software

"keri" wrote in message
oups.com...
Thank you.

Don Guillett wrote:
For NOT a number just insert NOT in front of isnumeric. Your original
request was for the column to the LEFT. If you want it to the right
change -1 to 1. Also, I did this for a range of cells in col F. If you
want
for only one cell just change to if activecell, etc

Len may be looked up in the vba help index

--
Don Guillett
SalesAid Software

"keri" wrote in message
ups.com...

Don Guillett wrote:
Sub ifallnum()
For Each c In Range("f2:f22")
If Len(c) 0 And IsNumeric(c) Then c.Offset(, -1) = 33
Next


Thanks. I'm guessing (with my small knowledge) this is supposed to put
33 into the column to the right of the selected cell if it IS an
integer. Is this correct? It's not working so far but i'll figure that
out, problem is I need to do it if it is NOT an integer. Can i do a "is
not"?

Oh and what is len?






All times are GMT +1. The time now is 09:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com