Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Required Field


I am trying to create a spread sheet that would require a person to fill
in certain fields before they could print a worksheet. Is this possible?


--
tiab86
------------------------------------------------------------------------
tiab86's Profile: http://www.excelforum.com/member.php...o&userid=25628
View this thread: http://www.excelforum.com/showthread...hreadid=530950

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Required Field

Put the following code in the ThisWorkbook module

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Worksheets("Sheet1").Range("A1") = "" Then '<<< change as
required
Cancel = True
End If
End Sub

Change the worksheet name and cell reference to the appropriate
values.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"tiab86"
wrote in message
...

I am trying to create a spread sheet that would require a
person to fill
in certain fields before they could print a worksheet. Is this
possible?


--
tiab86
------------------------------------------------------------------------
tiab86's Profile:
http://www.excelforum.com/member.php...o&userid=25628
View this thread:
http://www.excelforum.com/showthread...hreadid=530950



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Required Field

Use the beforeprint event to check
If they are not filled in, then display a msgbox and set the cancel variable
to True.

http://www.cpearson.com/excel/events.htm

for an overview of events.

--
Regards,
Tom Ogilvy


"tiab86" wrote:


I am trying to create a spread sheet that would require a person to fill
in certain fields before they could print a worksheet. Is this possible?


--
tiab86
------------------------------------------------------------------------
tiab86's Profile: http://www.excelforum.com/member.php...o&userid=25628
View this thread: http://www.excelforum.com/showthread...hreadid=530950


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Required Field


Ok,
I'm a bit confused.
When I put the values in below it appears to do nothing.
I'm new to VB so that's probably part of my problem.
What am I doing wrong?
I get the following error:


Run-time error '438':
Object doesn't support this property or method


Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Worksheets("Packing Slip").Range("U10") = "" Then '
Cancel = True
Print
End If
End Sub


--
tiab86
------------------------------------------------------------------------
tiab86's Profile: http://www.excelforum.com/member.php...o&userid=25628
View this thread: http://www.excelforum.com/showthread...hreadid=530950

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Required Field

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Worksheets("Packing Slip").Range("U10") = "" Then '
Cancel = True
End If
End Sub

You have already hit the print button, so you don't need to do anything for
it to print. What you are doing is cancelling that print if U10 of Packing
Slip is blank.

Immediately after Cancel=True you might want to put in

Msgbox "Printing cancelled until you put a value in U10"



--
Regards,
Tom Ogilvy



"tiab86" wrote:


Ok,
I'm a bit confused.
When I put the values in below it appears to do nothing.
I'm new to VB so that's probably part of my problem.
What am I doing wrong?
I get the following error:


Run-time error '438':
Object doesn't support this property or method


Private Sub Workbook_BeforePrint(Cancel As Boolean)
If Worksheets("Packing Slip").Range("U10") = "" Then '
Cancel = True
Print
End If
End Sub


--
tiab86
------------------------------------------------------------------------
tiab86's Profile: http://www.excelforum.com/member.php...o&userid=25628
View this thread: http://www.excelforum.com/showthread...hreadid=530950




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
can I make a field in excel spreadsheet required? If yes, How? Ginycub22 Excel Discussion (Misc queries) 0 August 23rd 06 08:30 PM
Required Field tiab86 Excel Worksheet Functions 0 April 6th 06 09:33 PM
Drop down - required field Tim T[_2_] Excel Programming 0 August 10th 05 09:21 PM
Required field message - Excel Steve S via OfficeKB.com Excel Discussion (Misc queries) 2 May 9th 05 04:16 PM
Field Required if another field is checked ** Kelly ******** Excel Programming 1 August 20th 03 10:44 PM


All times are GMT +1. The time now is 08:04 PM.

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

About Us

"It's about Microsoft Excel"