Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Satisfy Cell Requirements Before Printing

Hello.

My worksheet has three cells that are currently configured with the
Data Validation "List" criteria (with a default value of "Choose").
I would like to require the user to select another value before
printing the worksheet.

Does anyone know how I might code this so that: If the contents of
cell A1 and A2 and A3 are not equal to "Choose" then PRINT; otherwise
display a message box instructing the user to enter another value?

Thanks!!
Jessi

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Satisfy Cell Requirements Before Printing

Hi Jessi

Ok, Try this in the thisworkbook module for a sheet named Sheet1
It will check A1:C1

Private Sub Workbook_BeforePrint(Cancel As Boolean)
If ActiveSheet.Name = "Sheet1" Then
Cancel = True
Application.EnableEvents = False
If Application.WorksheetFunction.CountIf(Range("A1:C1 "), "Choose") 0 Then
MsgBox "change A1:C1"
Else
With ActiveSheet
.PrintOut
End With
End If
Application.EnableEvents = True
End If
End Sub



--
Regards Ron de Bruin
http://www.rondebruin.nl


wrote in message oups.com...
Hello.

My worksheet has three cells that are currently configured with the
Data Validation "List" criteria (with a default value of "Choose").
I would like to require the user to select another value before
printing the worksheet.

Does anyone know how I might code this so that: If the contents of
cell A1 and A2 and A3 are not equal to "Choose" then PRINT; otherwise
display a message box instructing the user to enter another value?

Thanks!!
Jessi



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Satisfy Cell Requirements Before Printing

Thank you, Ron:

If I put the first two lines (1) If ActiveSheet.Name = "Sheet1" Then
(2) Cancel = True, along with the argument in the Sub name (Cancel As
Boolean), then it returns the error "ARGUMENT NOT OPTIONAL"

If, however, I eliminate the above lines, it still PRINTS (but does NOT
display the message box) if the word "(Choose)" is still entered into
the cells.

If I modify the code from "" to "=" in the following line:
If Application.WorksheetFunction.CountIf(Range("$C$16 :$C$19"),
"(Choose)") = 0 Then
then it DISPLAYS the message box but does NOT print (regardless of what
is entered into the cells).

The code, as I currently have it, is listed in its entirety below:

Sub PrintAllSections()

'Unhide Sheet
Sheets("All Sheets").Visible = True
Sheets("All Sheets").Select
'Print the selected sheet
Application.EnableEvents = False
If Application.WorksheetFunction.CountIf(Range("$C$16 :$C$19"),
"(Choose)") = 0 Then
MsgBox "Change Divestiture Values"
Else
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
Application.EnableEvents = True
'Hide the Sheet
Sheets("All Sheets").Visible = False
Sheets("Barcode").Select
Range("C5").Select
'Protect the Sheet
ActiveSheet.Protect
End Sub

Did I miss something? If it matters, three of my cells are currently
formatted as text; the fourth cell is formatted as a date.

Thanks so much for your help!
Jessi

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Satisfy Cell Requirements Before Printing

I kept playing with this, and was able to make it work with ONE of the
cells (C16) by modifying the worksheet.range line. How could I get it
to also work with the other cells (C17, C18, and C19)?

Cell C18 is formatted as a date, but I had still typed "Choose" in the
cell as a default.

My code so far:

Sub PrintAllSections()

'Unhide Sheet
Sheets("All Sheets").Visible = True
Sheets("All Sheets").Select
'Print the selected sheet
If Worksheets("Barcode").Range("C16") = "Choose" Then
MsgBox "Change Divestiture Values"
Else
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
'Hide the Sheet and Move the Cursor
Sheets("All Sheets").Visible = False
Sheets("Barcode").Select
Range("C16").Select
'Protect the Sheet
ActiveSheet.Protect
End Sub

Thanks!
Jessi

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Satisfy Cell Requirements Before Printing

Hi

If you want to use a macro try this

"(Choose)"
Is this correct an not
"Choose")

Sub PrintAllSections()
If Application.WorksheetFunction.CountIf(Worksheets(" Barcode"). _
Range("C16:C19"), "(Choose)") 0 Then
MsgBox "Change Divestiture Values"
Else
With Sheets("All Sheets")
.Visible = True
.PrintOut
.Visible = False
End With
End If
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


wrote in message ups.com...
I kept playing with this, and was able to make it work with ONE of the
cells (C16) by modifying the worksheet.range line. How could I get it
to also work with the other cells (C17, C18, and C19)?

Cell C18 is formatted as a date, but I had still typed "Choose" in the
cell as a default.

My code so far:

Sub PrintAllSections()

'Unhide Sheet
Sheets("All Sheets").Visible = True
Sheets("All Sheets").Select
'Print the selected sheet
If Worksheets("Barcode").Range("C16") = "Choose" Then
MsgBox "Change Divestiture Values"
Else
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
'Hide the Sheet and Move the Cursor
Sheets("All Sheets").Visible = False
Sheets("Barcode").Select
Range("C16").Select
'Protect the Sheet
ActiveSheet.Protect
End Sub

Thanks!
Jessi





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Satisfy Cell Requirements Before Printing

This worked perfectly!! Thanks so much.

P.S. My default cell entry did originally have parenthese around it,
but I deleted them because it was causing confusion.

Thanks again!

Jessi

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
Wierd printing requirements between worksheets! mooneh Excel Discussion (Misc queries) 1 December 30th 08 08:25 AM
Material Requirements Plan (MRP) and Capacity Requirements Plan (C Tricia Young Excel Worksheet Functions 1 February 1st 07 06:55 AM
Material Requirements Planning-MRP/Capacity Requirements Planning- Tricia Young Excel Discussion (Misc queries) 1 February 1st 07 06:22 AM
make cell color change if requirements are met? PMLACC Excel Discussion (Misc queries) 2 July 14th 06 10:01 PM
Can I use the contents of a cell to satisfy the result_vector arg. robh_2 Excel Worksheet Functions 3 February 24th 05 08:14 PM


All times are GMT +1. The time now is 06:05 AM.

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"