Output the Immediate window to printer or screen

Folks,
I would like to add to the below code after the End Width the ability for the user to look at the  Immediate window and then elect to print out those results with the use of a MsgBox
?
Sub DocFormulaWks()
Dim rng As Range

With ActiveSheet
    For Each rng In .UsedRange
        If rng.HasFormula = True Then
        Debug.Print "Addr.: " & rng.Address
        Debug.Print "Form.: " & rng.Formula
        Debug.Print "Value : " & rng.Value
    End If
 Next rng
 End With
 End Sub

Open in new window

Frank FreeseAsked:
Who is Participating?
 
Martin LissConnect With a Mentor Older than dirtCommented:
Not quite. Move line 10 to just after line 12 or 13. In other words when you are all done with printing.
0
 
Martin LissOlder than dirtCommented:
The Immediate Window isn't functional except when debugging/developing.
0
 
Martin LissConnect With a Mentor Older than dirtCommented:
You could however send the same data to a label, picturebox, printer and/or some kind of report.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Frank FreeseAuthor Commented:
OK - so the output to the Immediate Window can not be sent to a printer but the data could. In the submitted code what would that look like, please.
0
 
Martin LissConnect With a Mentor Older than dirtCommented:
Just change Debug.Print to Printer.Print and at the end of that add Printer.EndDoc.
0
 
Frank FreeseAuthor Commented:
Like this?
Sub DocFormulaWks()			
Dim rng As Range			
			
With ActiveSheet			
    For Each rng In .UsedRange			
        If rng.HasFormula = True Then			
        Printer.Print "Addr.: " & rng.Address			
        Printer.Print "Form.: " & rng.Formula			
        Printer.Print "Value : " & rng.Value			
       Printer.EndDoc			
    End If			
 Next rng			
 End With			
End Sub			

Open in new window

0
 
Frank FreeseAuthor Commented:
thanks - I guess this is why they pay you the "big" bucks for people like me. As always, I appreciate you
0
 
Frank FreeseAuthor Commented:
great job!
0
 
Martin LissOlder than dirtCommented:
YW and thanks for the kind words.

Marty - MVP 2009 to 2013
0
 
[ fanpages ]IT Services ConsultantCommented:
thanks - I guess this is why they pay you the "big" bucks for people like me. As always, I appreciate you

When did the "Experts" get paid for providing answers to questions?

Am I missing out? ;)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.