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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
It works for me. Are you sure there isn't anything (like a space for example) in A1.
 
Upvote 0
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,214,576
Messages
6,120,350
Members
448,956
Latest member
Adamsxl

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
Back
Top