Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default message flash if sheet incomplete before printing

I have a sheet that requires certain fields to be filled in before printing.
Is it possible to have a message pop up if any of the fields have not been
completed when I click on the print button.

Thanks in advance of any help.

John
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default message flash if sheet incomplete before printing

Thanks for the code, however I might have misled you, the fields that need to
be completed, already have some data in them and these need to be overtyped.
I presume that your code checks to see if the cells are blank, but can I get
the message to pop up if some cells are already populated with speciifc data.
eg. Cell C1 = "Enter Reg. No.", cell C2 = "Enter Colour Code" etc.

Thanks again for any help

"Norman Jones" wrote:

Hi John,

Try:

'=============
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim SH As Worksheet
Dim rng As Range

Set SH = Me.Sheets("Sheet1") '<<==== CHANGE
Set rng = SH.Range("A1:C1") '<<==== CHANGE

If rng.Cells.Count Application.CountA(rng) Then
Cancel = True
MsgBox " All the cells in " & rng.Address(0, 0) _
& " on sheet " '& SH.Name _
& " need to be completed!"
End If

End Sub
'<<=============

This is workbook event code and should be pasted into the workbook's
ThisWorkbook module *not* a standard module or a sheet module:

Right-click the Excel icon on the worksheet
(or the icon to the left of the File menu if your workbook is maximised)
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.


---
Regards,
Norman


"John Davies" wrote in message
...
I have a sheet that requires certain fields to be filled in before
printing.
Is it possible to have a message pop up if any of the fields have not been
completed when I click on the print button.

Thanks in advance of any help.

John




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default message flash if sheet incomplete before printing

Hi John,

Try something like:

'=============
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim SH As Worksheet
Dim rng As Range
Dim rCell As Range
Dim arr As Variant
Dim i As Long

Set SH = Me.Sheets("Sheet1") '<<==== CHANGE
Set rng = SH.Range("C1:C3") '<<==== CHANGE

arr = Array("Enter Reg. No", "Enter Colour Code", _
"Enter something else") '<<==== CHANGE

For Each rCell In rng.Cells
i = i + 1
If rCell.Value = arr(i - 1) Or rCell.Value = "" Then
MsgBox " All the cells in " & rng.Address(0, 0) _
& " on sheet " & SH.Name _
& " need to be completed!"
Cancel = True
Exit For
i = i + 1
End If
Next rCell

End Sub
'<<=============


---
Regards,
Norman


"John Davies" wrote in message
...
Thanks for the code, however I might have misled you, the fields that need
to
be completed, already have some data in them and these need to be
overtyped.
I presume that your code checks to see if the cells are blank, but can I
get
the message to pop up if some cells are already populated with speciifc
data.
eg. Cell C1 = "Enter Reg. No.", cell C2 = "Enter Colour Code" etc.

Thanks again for any help

"Norman Jones" wrote:

Hi John,

Try:

'=============
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim SH As Worksheet
Dim rng As Range

Set SH = Me.Sheets("Sheet1") '<<==== CHANGE
Set rng = SH.Range("A1:C1") '<<==== CHANGE

If rng.Cells.Count Application.CountA(rng) Then
Cancel = True
MsgBox " All the cells in " & rng.Address(0, 0) _
& " on sheet " '& SH.Name _
& " need to be completed!"
End If

End Sub
'<<=============

This is workbook event code and should be pasted into the workbook's
ThisWorkbook module *not* a standard module or a sheet module:

Right-click the Excel icon on the worksheet
(or the icon to the left of the File menu if your workbook is maximised)
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.


---
Regards,
Norman


"John Davies" wrote in message
...
I have a sheet that requires certain fields to be filled in before
printing.
Is it possible to have a message pop up if any of the fields have not
been
completed when I click on the print button.

Thanks in advance of any help.

John






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default message flash if sheet incomplete before printing

Thanks Norman, that works fine, however to be a pain is it possible to
include code that will make the message flash and possibly change the colour
of the text and background.
Thanks again
John

"Norman Jones" wrote:

Hi John,

Try something like:

'=============
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim SH As Worksheet
Dim rng As Range
Dim rCell As Range
Dim arr As Variant
Dim i As Long

Set SH = Me.Sheets("Sheet1") '<<==== CHANGE
Set rng = SH.Range("C1:C3") '<<==== CHANGE

arr = Array("Enter Reg. No", "Enter Colour Code", _
"Enter something else") '<<==== CHANGE

For Each rCell In rng.Cells
i = i + 1
If rCell.Value = arr(i - 1) Or rCell.Value = "" Then
MsgBox " All the cells in " & rng.Address(0, 0) _
& " on sheet " & SH.Name _
& " need to be completed!"
Cancel = True
Exit For
i = i + 1
End If
Next rCell

End Sub
'<<=============


---
Regards,
Norman


"John Davies" wrote in message
...
Thanks for the code, however I might have misled you, the fields that need
to
be completed, already have some data in them and these need to be
overtyped.
I presume that your code checks to see if the cells are blank, but can I
get
the message to pop up if some cells are already populated with speciifc
data.
eg. Cell C1 = "Enter Reg. No.", cell C2 = "Enter Colour Code" etc.

Thanks again for any help

"Norman Jones" wrote:

Hi John,

Try:

'=============
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim SH As Worksheet
Dim rng As Range

Set SH = Me.Sheets("Sheet1") '<<==== CHANGE
Set rng = SH.Range("A1:C1") '<<==== CHANGE

If rng.Cells.Count Application.CountA(rng) Then
Cancel = True
MsgBox " All the cells in " & rng.Address(0, 0) _
& " on sheet " '& SH.Name _
& " need to be completed!"
End If

End Sub
'<<=============

This is workbook event code and should be pasted into the workbook's
ThisWorkbook module *not* a standard module or a sheet module:

Right-click the Excel icon on the worksheet
(or the icon to the left of the File menu if your workbook is maximised)
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.


---
Regards,
Norman


"John Davies" wrote in message
...
I have a sheet that requires certain fields to be filled in before
printing.
Is it possible to have a message pop up if any of the fields have not
been
completed when I click on the print button.

Thanks in advance of any help.

John






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default message flash if sheet incomplete before printing

Hi John,

MsgBoxes do not have flashing or formatting capabilities.

In any event, I think that most people would find flashing screens abhorrent
and, thus, you risk alienating your users.

Additionally, having effectively alerted the user to the need to populate
the required cells, and having also aborted the print operation, why not
quit while you are ahead?


---
Regards,
Norman



"John Davies" wrote in message
...
Thanks Norman, that works fine, however to be a pain is it possible to
include code that will make the message flash and possibly change the
colour
of the text and background.
Thanks again
John

"Norman Jones" wrote:

Hi John,

Try something like:

'=============
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim SH As Worksheet
Dim rng As Range
Dim rCell As Range
Dim arr As Variant
Dim i As Long

Set SH = Me.Sheets("Sheet1") '<<==== CHANGE
Set rng = SH.Range("C1:C3") '<<==== CHANGE

arr = Array("Enter Reg. No", "Enter Colour Code", _
"Enter something else") '<<==== CHANGE

For Each rCell In rng.Cells
i = i + 1
If rCell.Value = arr(i - 1) Or rCell.Value = "" Then
MsgBox " All the cells in " & rng.Address(0, 0) _
& " on sheet " & SH.Name _
& " need to be completed!"
Cancel = True
Exit For
i = i + 1
End If
Next rCell

End Sub
'<<=============


---
Regards,
Norman


"John Davies" wrote in message
...
Thanks for the code, however I might have misled you, the fields that
need
to
be completed, already have some data in them and these need to be
overtyped.
I presume that your code checks to see if the cells are blank, but can
I
get
the message to pop up if some cells are already populated with speciifc
data.
eg. Cell C1 = "Enter Reg. No.", cell C2 = "Enter Colour Code" etc.

Thanks again for any help

"Norman Jones" wrote:

Hi John,

Try:

'=============
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim SH As Worksheet
Dim rng As Range

Set SH = Me.Sheets("Sheet1") '<<==== CHANGE
Set rng = SH.Range("A1:C1") '<<==== CHANGE

If rng.Cells.Count Application.CountA(rng) Then
Cancel = True
MsgBox " All the cells in " & rng.Address(0, 0) _
& " on sheet " '& SH.Name _
& " need to be completed!"
End If

End Sub
'<<=============

This is workbook event code and should be pasted into the workbook's
ThisWorkbook module *not* a standard module or a sheet module:

Right-click the Excel icon on the worksheet
(or the icon to the left of the File menu if your workbook is
maximised)
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.


---
Regards,
Norman


"John Davies" wrote in message
...
I have a sheet that requires certain fields to be filled in before
printing.
Is it possible to have a message pop up if any of the fields have
not
been
completed when I click on the print button.

Thanks in advance of any help.

John








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
Incomplete Printing of Cell info. Kimberly New Users to Excel 4 October 8th 09 08:44 PM
removing incomplete entries in Excel sheet -keevill- Excel Discussion (Misc queries) 3 June 13th 08 03:15 AM
Web Query fails with "you need to upgrade flash" message Lin Parkh Excel Discussion (Misc queries) 1 May 21st 08 09:50 PM
how do you set up a field to flash upon entering sheet Al Excel Worksheet Functions 1 December 27th 07 03:00 PM
how can i avoid an error message while printing an excel sheet solidad Excel Discussion (Misc queries) 1 August 13th 06 01:00 PM


All times are GMT +1. The time now is 08:25 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"