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

Hi.
I am looking for a macro to not let blank and select the cell before
printing..
Thank you.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default No Blank Cell

I think I'd use an adjacent cell with a warning in it that clutters the
printout:

=if(a1="","","Invalid Report. A1 is not filled in!!!")
and give it a nice bold, red color.

But if you want, you could use an event macro. This goes behind the workbook
module:

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
With Me.Worksheets("sheet1").Range("a1")
If IsEmpty(.Value) Then
Application.Goto .Cells, scroll:=True
MsgBox "Can't print without that cell being filled"
Cancel = True
End If
End With
End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Chip Pearson has some instructions on events:
http://www.cpearson.com/excel/events.htm

David McRitchie has some notes, too:
http://www.mvps.org/dmcritchie/excel/event.htm

And the macro will not work if the user disables macros or disables events.


George wrote:

Hi.
I am looking for a macro to not let blank and select the cell before
printing..
Thank you.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default No Blank Cell


It works fine but I wanted to select the cell that left blank and add more
than 1 celle then
in VBA it types
Compile Error
Ambiguous name detected shovs up
is there a way to add more than 1 cell

Sincere Thanks...........
George.



"Dave Peterson" wrote in message
...
I think I'd use an adjacent cell with a warning in it that clutters the
printout:

=if(a1="","","Invalid Report. A1 is not filled in!!!")
and give it a nice bold, red color.

But if you want, you could use an event macro. This goes behind the
workbook
module:

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
With Me.Worksheets("sheet1").Range("a1")
If IsEmpty(.Value) Then
Application.Goto .Cells, scroll:=True
MsgBox "Can't print without that cell being filled"
Cancel = True
End If
End With
End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Chip Pearson has some instructions on events:
http://www.cpearson.com/excel/events.htm

David McRitchie has some notes, too:
http://www.mvps.org/dmcritchie/excel/event.htm

And the macro will not work if the user disables macros or disables
events.


George wrote:

Hi.
I am looking for a macro to not let blank and select the cell before
printing..
Thank you.


--

Dave Peterson



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default No Blank Cell

When you change the code, it's a good idea to post what you tried. It may give
a hint to what you need.

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim myCell As Range
Dim myRng As Range

Set myRng = Me.Worksheets("sheet1").Range("a1,b3,c12:c18")

If Application.CountA(myRng) = myRng.Cells.Count Then
'all filled in, do nothing
Else
For Each myCell In myRng.Cells
With myCell
If IsEmpty(.Value) Then
Application.Goto .Cells, scroll:=True
MsgBox "Can't print without all cells in: " _
& myRng.Address(0, 0) & " filled"
Cancel = True
Exit For
End If
End With
Next myCell
End If
End Sub



George wrote:

It works fine but I wanted to select the cell that left blank and add more
than 1 celle then
in VBA it types
Compile Error
Ambiguous name detected shovs up
is there a way to add more than 1 cell

Sincere Thanks...........
George.

"Dave Peterson" wrote in message
...
I think I'd use an adjacent cell with a warning in it that clutters the
printout:

=if(a1="","","Invalid Report. A1 is not filled in!!!")
and give it a nice bold, red color.

But if you want, you could use an event macro. This goes behind the
workbook
module:

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
With Me.Worksheets("sheet1").Range("a1")
If IsEmpty(.Value) Then
Application.Goto .Cells, scroll:=True
MsgBox "Can't print without that cell being filled"
Cancel = True
End If
End With
End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Chip Pearson has some instructions on events:
http://www.cpearson.com/excel/events.htm

David McRitchie has some notes, too:
http://www.mvps.org/dmcritchie/excel/event.htm

And the macro will not work if the user disables macros or disables
events.


George wrote:

Hi.
I am looking for a macro to not let blank and select the cell before
printing..
Thank you.


--

Dave Peterson


--

Dave Peterson
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
Average Formula to display blank cell if named range is blank Rachael F Excel Worksheet Functions 3 February 22nd 08 05:05 PM
Start Cell B1 then find first blank cell, insert subtotal, next non blank, then next blank, sutotal cells in between......... [email protected][_2_] Excel Programming 2 June 7th 07 09:27 PM
Need macro to check if cell is not blank & previous cell is blank, copy information from row above & paste JenIT Excel Programming 4 April 12th 07 08:56 PM
Copy to first Blank cell in Colum C Non blank cells still exist be Ulrik loves horses Excel Programming 2 October 8th 06 07:35 PM
COPY A CONCATENATE CELL TO BLANK CELL PUTTING IN THE NEXT BLANK C. QUEST41067 Excel Discussion (Misc queries) 1 January 15th 05 09:29 PM


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