Macro to Print only if text in a specific cell

Stelios Panayides

New Member
Joined
Jul 28, 2008
Messages
14
I am using the following macro to prevent printing if there is no text in a specific cell:

Sub Macro1()
Sheets("Sheet1").Select
If Range("A1") <> "." Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
End Sub

The macro is working fine and the sheet is not printed when in the cell there was only a dot.

But when I removed the dot (".") from the if statement i.e. use the macro:

Sub Macro1()
Sheets("Sheet1").Select
If Range("A1") <> "" Then
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End If
End Sub

the sheet is now printed.

Any ideas would be highly appreciated.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

VoG

Legend
Joined
Jun 19, 2002
Messages
63,650
It works for me. Are you sure there isn't anything (like a space for example) in A1.
 
Upvote 0

Stelios Panayides

New Member
Joined
Jul 28, 2008
Messages
14
Thanks for your response.

Actually cell A1 take the data from another cell in another sheet. Previously I used to have a dot in the empty cells but now I prefer them blank.
 
Upvote 0

Forum statistics

Threads
1,191,381
Messages
5,986,300
Members
440,017
Latest member
vasanrajeswaran

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top