Noob Question

G

Guest

I'm Getting Object Required. Run Time Error '424' . Trying to evaluate a
cell and If it's Null do the calculation MyItem = (Month(Now()) / 12 *
G4.Value) and place it cell G1 and if it's NOT Null use the Value in D3 Cell
which is a date and Replace the Now Function in my Calculation. Thanks for
the Help in Advance. O....

Sub MyEvaluate()
Dim MyItem As Long
If IsEmpty(Range("D3").Value) Then
MyItem = (Month(Now()) / 12 * G4.Value)
G1.Value = MyItem
End If
End Sub
 
B

Bob Umlas

G4.Value and G1.Value should both be
Range("G4").Value and Range("G1").Value because G4 and G1 are not objects -
Excel sees them as undeclared variables, hence Variants.
Instead of IsEmpty(Range("D3").Value) you want IsEmpty(Range("D3")) (no
".Value)
HTH
 
J

JE McGimpsey

One way:

Public Sub MyEvaluate()
If IsEmpty(Range("D3").Value) Then
Range("G1").Value = (Month(Date) / 12 * Range("G4").Value)
End If
End Sub
 
B

Bob Phillips

MyItem = (Month(Now()) / 12 * Range("G4").Value)
Range("G1").Value = MyItem


Do you really want to divide the month n umber by 12?


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
G

Guest

Sub MyEvaluate()
Dim MyItem As Long
If IsEmpty(Range("D3").Value) Then
MyItem = (Month(Now()) / 12 * Range("G4").Value)
Range("G1").Value = MyItem
End If
End Sub
 
G

Guest

O,

Try this >

Sub MyEvaluate()
Dim MyItem As Long
If IsEmpty(Range("D3").Value) Then
MyItem = (Month(Now()) / 12 * Range("G4").Value)
Range("G1").Value = MyItem
End If
End Sub
 
G

Guest

Thanks Guys.... One more question. Should I use a nested If or can I use
Else. If there's a date In (Range("D3").Value) I Want to take the Month of
"D3" / 12 * Range("G4").Value). Thanks

O......
 
B

Bob Phillips

If IsEmpty(Range("D3").Value) Then
MyItem = (Month(Now()) / 12 * Range("G4").Value)
Else
MyItem = (Month(Range("D3").Value) / 12 * Range("G4").Value)
End If
Range("G1").Value = MyItem

or even

myItem = Month(IIf(IsEmpty(Range("D3").Value), Now(),
Range("D3").Value)) / 12 * Range("G4").Value
Range("G1").Value = myItem


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top