Some times we have some information in worksheet which is we need to input but do not want that information to be printed. With the following macro code you can achieve the desired results
You will need to
copy this code to workbook module of your workbook
Private Sub Workbook_BeforePrint(Cancel As Boolean) Application.EnableEvents = False Cancel = True A = Range("A1").NumberFormat Range("A1").NumberFormat = ";;;" Application.Dialogs(xlDialogPrint).Show Range("A1").NumberFormat = A Application.EnableEvents = True
End Sub
|
As per above code the contents of Range A1 will not be printed, you will need to change this reference to your cell.
Download file with the code to hide cell contents before printing
.
7 comments:
Doesn't exactly work for me. I'm trying to hide a range of cells in a sheet (e.g. B7-D9). I tried the code:
Range("B7:D9").NumberFormat = ";;;"
But that didn't work.
Hello Chris
I hope that you have enabled macros. Macros needs to be enabled to have this working.
If you have macros enabled, make sure that it has been added to workbook module of your file.
Also you will need to change the reference range at 3 places but this should not impact hiding contents. I suggest that you download file available at download link of the post and then change the refernce range to see how this works.
Again make sure that you have enabled macros.
Thanks
Yogesh Gupta
myself Ravishankar in our office we get a report from oracle based software like on sorted and its taking hell out my time pls help me out to do the same if you can suggest me
Hi Ravi
I am not clear on what do you want. Can you be more specific about your question.
Regards//Yogesh Gupta
Hi Yogesh
actually we using oracle software and we getting daily reports which in un sorted condition with extra lines which is taking too much time for me to sort and analyzing the report
so can you help in this...
Hi Ravi
I can suggest some thing if I know the exact details of problem along with the resolution you want for it. What ever you have said is very generic and can not be commented upon for soultion
Regards//Yogesh Gupta
Yogesh one of my office mate locked excel file and he left job we keep trying to contact him and not responsing for anything, Pls not the spread sheet total file locked, means when we try to open the file Excel prompting the password
Pls help since this contain my full year finance data
Post a Comment