Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default before_print does not work - f8 key does not do anything

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default before_print does not work - f8 key does not do anything

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default before_print does not work - f8 key does not do anything


Thank you very much for your help.
Nasim

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
flash object dont work in my excel work sheet Nitn Excel Discussion (Misc queries) 0 July 4th 09 08:00 AM
Before_Print JMay Excel Programming 10 November 12th 06 06:27 PM
If I have a work sheet protected and try to run a macro to hide rows or columns it won't work. Correct? Marc Excel Programming 2 July 12th 06 04:10 AM
Counting dates in multiple work sheets and work books Savage Excel Discussion (Misc queries) 0 December 19th 05 11:41 PM
Re-Post: Before_Print Sub Doesn't Trigger Phil Hageman[_3_] Excel Programming 27 March 4th 04 04:03 AM


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