Good morning
I’m endeavouring to develop script that runs a msgbox based on a formula result.
The first part is a macro that counts how many times it is ran on a particular day.
The second part is if the count is >1 then a msgbox is activated to alert the user.
I have used the following for first part: in a Module
Sub Data()
'Macro1 Macro
Sheets("Sheet2").Select
With Sheets("Sheet2")
If .Range("B1") <> Date Then
.Range("B1") = Date
.Range("A1") = 0
End If
.Range("A1") = Range("A1") + 1
End With
Sheets("Sheet1").Select
Range("B2").Select
ActiveCell.FormulaR1C1 = "1"
Range("b3").Select
ActiveCell.FormulaR1C1 = "2"
Range("b4").Select
ActiveCell.FormulaR1C1 = "3"
Range("b5").Select
ActiveCell.FormulaR1C1 = "4"
End Sub
This macro works perfectly (thanks to MrExcel)
I have tried to develop the following for second part from script I found on the web: under sheet 2 (where the data is held)
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Response
Dim Isect As Range
Set Isect = Application.Intersect(Target, Range("A1"))
If Not (Isect Is Nothing) And Range("A1") > 1 Then
Response = MsgBox("Alert! The Data macro has been run more than once today", vbOKOnly)
End If
End Sub
Before I tried the second part macro count works fine. Adding second part I get an error “Sheets("Sheet2").Select
Your advice would be much appreciated
Geoff
I’m endeavouring to develop script that runs a msgbox based on a formula result.
The first part is a macro that counts how many times it is ran on a particular day.
The second part is if the count is >1 then a msgbox is activated to alert the user.
I have used the following for first part: in a Module
Sub Data()
'Macro1 Macro
Sheets("Sheet2").Select
With Sheets("Sheet2")
If .Range("B1") <> Date Then
.Range("B1") = Date
.Range("A1") = 0
End If
.Range("A1") = Range("A1") + 1
End With
Sheets("Sheet1").Select
Range("B2").Select
ActiveCell.FormulaR1C1 = "1"
Range("b3").Select
ActiveCell.FormulaR1C1 = "2"
Range("b4").Select
ActiveCell.FormulaR1C1 = "3"
Range("b5").Select
ActiveCell.FormulaR1C1 = "4"
End Sub
This macro works perfectly (thanks to MrExcel)
I have tried to develop the following for second part from script I found on the web: under sheet 2 (where the data is held)
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Response
Dim Isect As Range
Set Isect = Application.Intersect(Target, Range("A1"))
If Not (Isect Is Nothing) And Range("A1") > 1 Then
Response = MsgBox("Alert! The Data macro has been run more than once today", vbOKOnly)
End If
End Sub
Before I tried the second part macro count works fine. Adding second part I get an error “Sheets("Sheet2").Select
Your advice would be much appreciated
Geoff