Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have defined the following value for a cell within my macro
Range("K" & i).Select ActiveCell.FormulaR1C1 = _ "=((YEAR(RC[-1])-YEAR(RC[-2]))*12)+(MONTH(RC[-1])-MONTH(RC[-2]))" If the value of this range is 0, I want to do other things. I'm not sure how to write an "IF" statement to capture this information. How do I do that? Thanks in advance, Barb Reinhardt |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Something like this perhaps:-
If ActiveCell.Value 0 Then ' put here what you want to happen i.e. MsgBox "it's working!!" End If "Barb Reinhardt" wrote: I have defined the following value for a cell within my macro Range("K" & i).Select ActiveCell.FormulaR1C1 = _ "=((YEAR(RC[-1])-YEAR(RC[-2]))*12)+(MONTH(RC[-1])-MONTH(RC[-2]))" If the value of this range is 0, I want to do other things. I'm not sure how to write an "IF" statement to capture this information. How do I do that? Thanks in advance, Barb Reinhardt |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Range("K" & i).Activate
ActiveCell.FormulaR1C1 = _ "=((YEAR(RC[-1])-YEAR(RC[-2]))*12)+(MONTH(RC[-1])-MONTH(RC[-2]))" ActiveCell.Value 0 Then 'do something Else 'do something else End If Hutch -------------------------------- "Barb Reinhardt" wrote: I have defined the following value for a cell within my macro Range("K" & i).Select ActiveCell.FormulaR1C1 = _ "=((YEAR(RC[-1])-YEAR(RC[-2]))*12)+(MONTH(RC[-1])-MONTH(RC[-2]))" If the value of this range is 0, I want to do other things. I'm not sure how to write an "IF" statement to capture this information. How do I do that? Thanks in advance, Barb Reinhardt |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks. The ActiveCell.Value part was what I needed.
Now I have another question. How do I check to see If ActiveCell.Value = #N/A. I can't seem to figure this one out. "bigwheel" wrote: Something like this perhaps:- If ActiveCell.Value 0 Then ' put here what you want to happen i.e. MsgBox "it's working!!" End If "Barb Reinhardt" wrote: I have defined the following value for a cell within my macro Range("K" & i).Select ActiveCell.FormulaR1C1 = _ "=((YEAR(RC[-1])-YEAR(RC[-2]))*12)+(MONTH(RC[-1])-MONTH(RC[-2]))" If the value of this range is 0, I want to do other things. I'm not sure how to write an "IF" statement to capture this information. How do I do that? Thanks in advance, Barb Reinhardt |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Barb,
Now I have another question. How do I check to see If ActiveCell.Value = #N/A. I can't seem to figure this one out. Try If Application.WorksheetFunction.IsNA(ActiveCell.Valu e) Then Debug.Print "is n/a" Else Debug.Print "not n/a" End If -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Barb Reinhardt" wrote in message ... Thanks. The ActiveCell.Value part was what I needed. Now I have another question. How do I check to see If ActiveCell.Value = #N/A. I can't seem to figure this one out. "bigwheel" wrote: Something like this perhaps:- If ActiveCell.Value 0 Then ' put here what you want to happen i.e. MsgBox "it's working!!" End If "Barb Reinhardt" wrote: I have defined the following value for a cell within my macro Range("K" & i).Select ActiveCell.FormulaR1C1 = _ "=((YEAR(RC[-1])-YEAR(RC[-2]))*12)+(MONTH(RC[-1])-MONTH(RC[-2]))" If the value of this range is 0, I want to do other things. I'm not sure how to write an "IF" statement to capture this information. How do I do that? Thanks in advance, Barb Reinhardt |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
One more way:
if activecell.text = "#N/A" then Barb Reinhardt wrote: Thanks. The ActiveCell.Value part was what I needed. Now I have another question. How do I check to see If ActiveCell.Value = #N/A. I can't seem to figure this one out. "bigwheel" wrote: Something like this perhaps:- If ActiveCell.Value 0 Then ' put here what you want to happen i.e. MsgBox "it's working!!" End If "Barb Reinhardt" wrote: I have defined the following value for a cell within my macro Range("K" & i).Select ActiveCell.FormulaR1C1 = _ "=((YEAR(RC[-1])-YEAR(RC[-2]))*12)+(MONTH(RC[-1])-MONTH(RC[-2]))" If the value of this range is 0, I want to do other things. I'm not sure how to write an "IF" statement to capture this information. How do I do that? Thanks in advance, Barb Reinhardt -- Dave Peterson |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How about if the cell value is #Value! ???
"Dave Peterson" wrote: One more way: if activecell.text = "#N/A" then Barb Reinhardt wrote: Thanks. The ActiveCell.Value part was what I needed. Now I have another question. How do I check to see If ActiveCell.Value = #N/A. I can't seem to figure this one out. "bigwheel" wrote: Something like this perhaps:- If ActiveCell.Value 0 Then ' put here what you want to happen i.e. MsgBox "it's working!!" End If "Barb Reinhardt" wrote: I have defined the following value for a cell within my macro Range("K" & i).Select ActiveCell.FormulaR1C1 = _ "=((YEAR(RC[-1])-YEAR(RC[-2]))*12)+(MONTH(RC[-1])-MONTH(RC[-2]))" If the value of this range is 0, I want to do other things. I'm not sure how to write an "IF" statement to capture this information. How do I do that? Thanks in advance, Barb Reinhardt -- Dave Peterson |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
if activecell.text = "#Value!" then
or if iserror(activecell.value) then to catch all kinds of errors Barb Reinhardt wrote: How about if the cell value is #Value! ??? "Dave Peterson" wrote: One more way: if activecell.text = "#N/A" then Barb Reinhardt wrote: Thanks. The ActiveCell.Value part was what I needed. Now I have another question. How do I check to see If ActiveCell.Value = #N/A. I can't seem to figure this one out. "bigwheel" wrote: Something like this perhaps:- If ActiveCell.Value 0 Then ' put here what you want to happen i.e. MsgBox "it's working!!" End If "Barb Reinhardt" wrote: I have defined the following value for a cell within my macro Range("K" & i).Select ActiveCell.FormulaR1C1 = _ "=((YEAR(RC[-1])-YEAR(RC[-2]))*12)+(MONTH(RC[-1])-MONTH(RC[-2]))" If the value of this range is 0, I want to do other things. I'm not sure how to write an "IF" statement to capture this information. How do I do that? Thanks in advance, Barb Reinhardt -- Dave Peterson -- Dave Peterson |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
For some reason, it didn't work as I expected ... and then I realized I'd
goofed something else up. Thanks. "Dave Peterson" wrote: if activecell.text = "#Value!" then or if iserror(activecell.value) then to catch all kinds of errors Barb Reinhardt wrote: How about if the cell value is #Value! ??? "Dave Peterson" wrote: One more way: if activecell.text = "#N/A" then Barb Reinhardt wrote: Thanks. The ActiveCell.Value part was what I needed. Now I have another question. How do I check to see If ActiveCell.Value = #N/A. I can't seem to figure this one out. "bigwheel" wrote: Something like this perhaps:- If ActiveCell.Value 0 Then ' put here what you want to happen i.e. MsgBox "it's working!!" End If "Barb Reinhardt" wrote: I have defined the following value for a cell within my macro Range("K" & i).Select ActiveCell.FormulaR1C1 = _ "=((YEAR(RC[-1])-YEAR(RC[-2]))*12)+(MONTH(RC[-1])-MONTH(RC[-2]))" If the value of this range is 0, I want to do other things. I'm not sure how to write an "IF" statement to capture this information. How do I do that? Thanks in advance, Barb Reinhardt -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Force entry into cell, based on validation selection in adjacent cell | Excel Worksheet Functions | |||
Writing a macro to hide columns based on cell value | Excel Discussion (Misc queries) | |||
Change Text Color in one cell based upon entry in referenced cell | Excel Discussion (Misc queries) | |||
restricting entry into a cell based on entry to a previous cell | New Users to Excel | |||
Input boxes - writing entry to cell | Excel Programming |