PC Review


Reply
Thread Tools Rate Thread

before_print does not work - f8 key does not do anything

 
 
Nasim
Guest
Posts: n/a
 
      3rd Dec 2006
Hi, i have a before_print event which does not work and i don't
understand y not. i also can't debug it. i put a break point at the end
sub line and i press f8 but nothing happens and the computer beeps.
would you please help me to understand what i am doing wrog? cell C9 is
a drop down list and codes are in this workbook module. i have
conditional formating for cells that should be filled out by users
according to their dropdown list selection.

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim i As Integer
Dim cell As Range

i = 0
If Sheets(1).Range("c9").Text = "abcd" Then
Sheets(1).Range("c12:c19", "j9", "j11", "i13", "i15", "i17",
"i19").Select
For Each cell In Selection
If IsEmpty(cell) Then
i = i + 1
End If
Next cell
If i > 0 Then
MsgBox "Please fill out all the mandatory fields which are
colored in yellow"
Cancel = True
End If
End If
End Sub

 
Reply With Quote
 
 
 
 
wisccal@googlemail.com
Guest
Posts: n/a
 
      3rd Dec 2006
I believe you need to change the following line:

Sheets(1).Range("c12:c19", "j9", "j11", "i13", "i15", "i17",
"i19").Select

to:

Sheets(1).Range("c12:c19, j9, j11, i13, i15, i17, i19").Select

Also, you would not put a breakpoint at the end of the sub. Insert it
on a line before the line that produces the error (highlighted in
yellow). Run the macro by hitting F5, and the code will stop at the
break point. Now you can step through the code line by line with F8.

Regards,
Steve
www.stkomp.com

Nasim wrote:
> Hi, i have a before_print event which does not work and i don't
> understand y not. i also can't debug it. i put a break point at the end
> sub line and i press f8 but nothing happens and the computer beeps.
> would you please help me to understand what i am doing wrog? cell C9 is
> a drop down list and codes are in this workbook module. i have
> conditional formating for cells that should be filled out by users
> according to their dropdown list selection.
>
> Private Sub Workbook_BeforePrint(Cancel As Boolean)
> Dim i As Integer
> Dim cell As Range
>
> i = 0
> If Sheets(1).Range("c9").Text = "abcd" Then
> Sheets(1).Range("c12:c19", "j9", "j11", "i13", "i15", "i17",
> "i19").Select
> For Each cell In Selection
> If IsEmpty(cell) Then
> i = i + 1
> End If
> Next cell
> If i > 0 Then
> MsgBox "Please fill out all the mandatory fields which are
> colored in yellow"
> Cancel = True
> End If
> End If
> End Sub


 
Reply With Quote
 
Nasim
Guest
Posts: n/a
 
      4th Dec 2006

Thank you very much for your help.
Nasim

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Before_Print event Jan Kronsell Microsoft Excel Programming 3 28th Aug 2008 08:49 PM
Before_Print =?Utf-8?B?Um9iaW4gQ2xheQ==?= Microsoft Excel Programming 2 13th Feb 2007 12:41 PM
Before_Print JMay Microsoft Excel Programming 10 12th Nov 2006 06:27 PM
Re-Post: Before_Print Sub Doesn't Trigger =?Utf-8?B?UGhpbCBIYWdlbWFu?= Microsoft Excel Programming 27 4th Mar 2004 04:03 AM


Features
 

Advertising
 

Newsgroups
 


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