VBA?

P

PeCoNe

I start a new Excel sheet with Excel 2010.
I need to check cell B2 on open if it contains the date of today.
If not I need to place today's date in B2 and clear the cells
D3,F3,H3,I3 and D4:I4.
During the day cell F4 receives a new value and the cell F3 the time.
I need to keep the lowest value in D4 and the time in D3 and
I need to keep the highest value in H4 and the time in H3

I think that is possible with VBA.
The problem is: I don't know anything of VBA.

So please help.
 
I

isabelle

hi PeCoNe,

'I need to check cell B2 on open if it contains the date of today.
'If not I need to place today's date in B2 and clear the cells
D3,F3,H3,I3 and D4:I4.

Private Sub Workbook_Open()
If Not Sheets("Sheet1").Range("B2") = Date Then
Sheets("Sheet1").Range("B2") = Date
Application.Union(Range("D3"), Range("F3"), Range("H3"), Range("I3"),
Range("D4:I4")).ClearContents
End If
End Sub

regarding other treatments (During the day) i do not know with what
events it must be executed.

isabelle



Le 2012-12-22 12:30, PeCoNe a écrit :
 
I

isabelle

better that way,

Private Sub Worksheet_Activate()
If Not Sheets("Sheet1").Range("B2") = Date Then
With Sheets("Sheet1")
.Range("B2") = Date
Application.Union(.Range("D3"), .Range("F3"), .Range("H3"),
..Range("I3"), .Range("D4:I4")).ClearContents
End With
End If
End Sub


isabelle
 
P

PeCoNe

Op 2012-12-30 04:14, isabelle schreef:
better that way,

Private Sub Worksheet_Activate()
If Not Sheets("Sheet1").Range("B2") = Date Then
With Sheets("Sheet1")
.Range("B2") = Date
Application.Union(.Range("D3"), .Range("F3"), .Range("H3"),
.Range("I3"), .Range("D4:I4")).ClearContents
End With
End If
End Sub


isabelle

Hallo Isabelle,

I did it this way (after many tries):
Private Sub Workbook_Open()

Workbooks("Signals").Sheets("Monitor").Activate
If Weekday(Date) > 1 And Weekday(Date) < 7 Then ' Only on Monday-Friday
If Not Range("C2").Value = Date Then
Range("C2").Value = Date
Range("FieldsToClear").ClearContents
End If
End If

End Sub

bye Peter Maljers
 

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