Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.newusers
 
Posts: n/a
Default Required fields in Excel

I'm brand new to using VB.

I have been playing around with setting up required fields in Excel. I
was lucky to find a post with the following code:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Worksheets("Sheet1").Range("A2").Value = "" Then
Cancel = True
MsgBox "Please Fill-In A2"
End If
End Sub

I have tested this and it works fine. This basically ensures that excel
can't be saved unless the specified cells are filled in.

Now for a really stupid question. How do I save this script to the
excel workbook so that I can distribute to other users? Obviously if I
try and save the workbook itself it prompts me to enter the required
fields before saving, and if I just close without saving the script is
lost.

Any suggestions would be appreciated.

Thanks,

Jim

  #2   Report Post  
Posted to microsoft.public.excel.newusers
JMB
 
Posts: n/a
Default Required fields in Excel

Try disabling events on your machine. In the VB editor, open the Immediate
Window and type

Application.EnableEvents=False

Save the workbook, then set back to true.


" wrote:

I'm brand new to using VB.

I have been playing around with setting up required fields in Excel. I
was lucky to find a post with the following code:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Worksheets("Sheet1").Range("A2").Value = "" Then
Cancel = True
MsgBox "Please Fill-In A2"
End If
End Sub

I have tested this and it works fine. This basically ensures that excel
can't be saved unless the specified cells are filled in.

Now for a really stupid question. How do I save this script to the
excel workbook so that I can distribute to other users? Obviously if I
try and save the workbook itself it prompts me to enter the required
fields before saving, and if I just close without saving the script is
lost.

Any suggestions would be appreciated.

Thanks,

Jim


  #3   Report Post  
Posted to microsoft.public.excel.newusers
CLR
 
Posts: n/a
Default Required fields in Excel

Hi Jim.........
Try this "password" approach..........

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Worksheets("Sheet1").Range("A2").Value = "xxx" Then
End
End If
If Worksheets("Sheet1").Range("A2").Value = "" Then
Cancel = True
MsgBox "Please Fill-In A2"
End If

End Sub

" wrote:

I'm brand new to using VB.

I have been playing around with setting up required fields in Excel. I
was lucky to find a post with the following code:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Worksheets("Sheet1").Range("A2").Value = "" Then
Cancel = True
MsgBox "Please Fill-In A2"
End If
End Sub

I have tested this and it works fine. This basically ensures that excel
can't be saved unless the specified cells are filled in.

Now for a really stupid question. How do I save this script to the
excel workbook so that I can distribute to other users? Obviously if I
try and save the workbook itself it prompts me to enter the required
fields before saving, and if I just close without saving the script is
lost.

Any suggestions would be appreciated.

Thanks,

Jim


  #4   Report Post  
Posted to microsoft.public.excel.newusers
CLR
 
Posts: n/a
Default Required fields in Excel

Sorry, sent before finishing.........I meant to add that you can change the
"xxx" to be any "password" that you choose, just for the purpose of being
able to save the workbook without triggering the main intent of your
macro......and of course you can also put that password in another
cell............but hmmmmm, I guess it gets curiouser and curiouser cause
then you would need a WorksheetOpen event to delete the password when a user
opens the file or it would be there all the time...........ugh

Vaya con Dios,
Chuck, CABGx3



"CLR" wrote:

Hi Jim.........
Try this "password" approach..........

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Worksheets("Sheet1").Range("A2").Value = "xxx" Then
End
End If
If Worksheets("Sheet1").Range("A2").Value = "" Then
Cancel = True
MsgBox "Please Fill-In A2"
End If

End Sub

" wrote:

I'm brand new to using VB.

I have been playing around with setting up required fields in Excel. I
was lucky to find a post with the following code:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
If Worksheets("Sheet1").Range("A2").Value = "" Then
Cancel = True
MsgBox "Please Fill-In A2"
End If
End Sub

I have tested this and it works fine. This basically ensures that excel
can't be saved unless the specified cells are filled in.

Now for a really stupid question. How do I save this script to the
excel workbook so that I can distribute to other users? Obviously if I
try and save the workbook itself it prompts me to enter the required
fields before saving, and if I just close without saving the script is
lost.

Any suggestions would be appreciated.

Thanks,

Jim


  #5   Report Post  
Posted to microsoft.public.excel.newusers
 
Posts: n/a
Default Required fields in Excel

Thanks a lot for your suggestions!!

Will try tonight.

Cheers,

Jim



  #6   Report Post  
Junior Member
 
Posts: 1
Default

Quote:
Originally Posted by View Post
Thanks a lot for your suggestions!!

Will try tonight.

Cheers,

Jim
Hi,

I'm also new to VBA and I'm using Excel 2010. I've tried using the code on this forum and have tried several others on other forums similar to it. Each time I attempt to test if this will work the workbork saves and does not prompt me to enter any missing information.

Am I missing a step?

Any help appreciated,
Jlofton
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 FAILS, but Excel 2000 SUCCEEDS ??? Richard Excel Discussion (Misc queries) 2 May 13th 23 11:46 AM
Stop excel from dropping the 0 in the beginning of a number? Rosewood Setting up and Configuration of Excel 12 April 4th 23 02:12 PM
Feature to flag unpopulated required fields in Excel? Sarah Excel Discussion (Misc queries) 1 February 27th 06 08:02 PM
Importing data from Access into Excel: prob w/ cutting off fields Nicole L. Excel Worksheet Functions 1 February 7th 05 10:05 PM
Use Excel fields in Word document Brent Excel Discussion (Misc queries) 1 December 9th 04 05:36 PM


All times are GMT +1. The time now is 01:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"