Noob Question 2

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......
 
Z

Zone

Sub MyEvaluate()
Dim MyItem As Double
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
End Sub
 
G

Guest

Thanks Zone, How do I Execute it for Multiply worksheets when the work book
is open
 
G

Guest

I have a workbook called Vacation Accurred within that workbook I have
Wooksheets for John Doe, Jane Doe, Joe Smith, Suzzie Jones, etc I Want to
execute that code when the Wookbook is open for all Worksheets (John Doe,
Jane Doe, Suzzie Jones and So On.....

thanks...
 
G

Guest

Vacation Accrued, Sorry I'm half retarded

O.... said:
I have a workbook called Vacation Accurred within that workbook I have
Wooksheets for John Doe, Jane Doe, Joe Smith, Suzzie Jones, etc I Want to
execute that code when the Wookbook is open for all Worksheets (John Doe,
Jane Doe, Suzzie Jones and So On.....

thanks...
 
Z

Zone

To do this on all the worksheets when the workbook is opened, copy this code
and paste in the Workbook Module. On my machine (Excel XP), you can find
this module by showing one of the spreadsheets, right-click on the Excel
icon on the very left side of the menubar, and select View Code. Paste the
code in there. When you open the workbook the next time, it will run on all
sheets. Hope this helps, James

Private Sub Workbook_Open()
Dim MyItem As Double, ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Activate
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
Next ws
End Sub
 

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

Top