ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to force cell entry before running (https://www.excelbanter.com/excel-programming/328145-macro-force-cell-entry-before-running.html)

Chance224

Macro to force cell entry before running
 
I have a macro that copies a master sheet and places at the end of the
workbook by clicking a button. Is there away to have it force the user to
put the start date in a cell then continue with the macro once a value is
entered?


Thanks,
CJ


Don Guillett[_4_]

Macro to force cell entry before running
 
We always prefer that you post your macro here for comments
Sub checkg9()
If Not IsDate(Range("g9")) Then MsgBox "fix date"
End Sub
--
Don Guillett
SalesAid Software

"Chance224" wrote in message
...
I have a macro that copies a master sheet and places at the end of the
workbook by clicking a button. Is there away to have it force the user to
put the start date in a cell then continue with the macro once a value is
entered?


Thanks,
CJ




Chance224

Macro to force cell entry before running
 
The following is the Macro used. How do I insert your macro to run with
this? I would like is to force an entry into cell BR15 if it is blank and
then continue to copy the sheet.

Sub Copy_Click()
'
'
Sheets(" Master").Copy After:=Sheets(ActiveWorkbook.Worksheets.Count)
ActiveSheet.Range("AC3").Value = "Enter Date"
ActiveSheet.Range("K7").Value = "Enter Well Number"
ActiveSheet.Range("AY104").Formula = "=AY101+'" & ActiveSheet.Previous.Name _
& "'!AY104"

MsgBox ("Please Change The DATE & WELL NUMBER. Thank You & Stay Safe!
Remember You Can ONLY Use - For Date Entries")

End Sub

Thanks,
CJ

"Don Guillett" wrote:

We always prefer that you post your macro here for comments
Sub checkg9()
If Not IsDate(Range("g9")) Then MsgBox "fix date"
End Sub
--
Don Guillett
SalesAid Software

"Chance224" wrote in message
...
I have a macro that copies a master sheet and places at the end of the
workbook by clicking a button. Is there away to have it force the user to
put the start date in a cell then continue with the macro once a value is
entered?


Thanks,
CJ





Jim Thomlinson[_3_]

Macro to force cell entry before running
 
How about propmting the user for the start date using an input box. If they
eneter a date then create the sheet otherwise dispaly a message... Something
like this...

Public Sub CopyMaster()
Dim wksMaster As Worksheet
Dim wksCopy As Worksheet
Dim strStartDate As Date

strStartDate = InputBox("Please enter the start date.")

If IsDate(strStartDate) Then

Set wksMaster = Sheets("Master")
wksMaster.Copy After:=Sheets(Sheets.Count)
Set wksCopy = ActiveSheet
wksCopy.Range("A1").Value = CDate(strStartDate)

wksMaster.Select
Set wksCopy = Nothing
Set wksMaster = Nothing

Else
MsgBox "Invalid Start Date. Please try again."
End If

End Sub

"Chance224" wrote:

I have a macro that copies a master sheet and places at the end of the
workbook by clicking a button. Is there away to have it force the user to
put the start date in a cell then continue with the macro once a value is
entered?


Thanks,
CJ


Don Guillett[_4_]

Macro to force cell entry before running
 
as suggested by Jim, use an input box
Range("AC3").Value = inputbox("Enter Date")
'then
If Not IsDate(Range("ac3")) Then MsgBox "fix date"
'to check it

Don Guillett
SalesAid Software

"Chance224" wrote in message
...
The following is the Macro used. How do I insert your macro to run with
this? I would like is to force an entry into cell BR15 if it is blank and
then continue to copy the sheet.

Sub Copy_Click()
'
'
Sheets(" Master").Copy After:=Sheets(ActiveWorkbook.Worksheets.Count)
ActiveSheet.Range("AC3").Value = "Enter Date"
ActiveSheet.Range("K7").Value = "Enter Well Number"
ActiveSheet.Range("AY104").Formula = "=AY101+'" &

ActiveSheet.Previous.Name _
& "'!AY104"

MsgBox ("Please Change The DATE & WELL NUMBER. Thank You & Stay Safe!
Remember You Can ONLY Use - For Date Entries")

End Sub

Thanks,
CJ

"Don Guillett" wrote:

We always prefer that you post your macro here for comments
Sub checkg9()
If Not IsDate(Range("g9")) Then MsgBox "fix date"
End Sub
--
Don Guillett
SalesAid Software

"Chance224" wrote in message
...
I have a macro that copies a master sheet and places at the end of the
workbook by clicking a button. Is there away to have it force the

user to
put the start date in a cell then continue with the macro once a value

is
entered?


Thanks,
CJ








All times are GMT +1. The time now is 12:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com