moe10134
Board Regular
- Joined
- Sep 8, 2005
- Messages
- 162
- Office Version
- 2019
- Platform
- Windows
Hello,
I have a macro that is designed to print all text from Column A to print a list of all data except the blank cells. This is my macro, but it is not printing.
I have it assigned to a Command Button. Is the print menu supposed to pop up or will it just print to my default printer?
Is this the correct macro to use? When I execute it I don't get any error, but it just won't print anything at all.
Can someone please help? Or Create a new macro that will print only the text as a list of non-blank cells?
Thanks much,
MOE10134
Private Sub CommandButton1_Click()
Dim myFile As String, rng As Range, cellValue As Variant, i As Integer, j As Integer
myFile = Application.DefaultFilePath & "\NumeroChamados.txt"
Set rng = Selection
Open myFile For Output As #1
For i = 1 To rng.Rows.Count
For j = 1 To rng.Columns.Count
cellValue = rng.Cells(i, j).Value
If j = rng.Columns.Count Then
Print #1 , cellValue,
Else
Print #1 , cellValue,
End If
Next j
Next i
Close #1
End Sub
I have a macro that is designed to print all text from Column A to print a list of all data except the blank cells. This is my macro, but it is not printing.
I have it assigned to a Command Button. Is the print menu supposed to pop up or will it just print to my default printer?
Is this the correct macro to use? When I execute it I don't get any error, but it just won't print anything at all.
Can someone please help? Or Create a new macro that will print only the text as a list of non-blank cells?
Thanks much,
MOE10134
Private Sub CommandButton1_Click()
Dim myFile As String, rng As Range, cellValue As Variant, i As Integer, j As Integer
myFile = Application.DefaultFilePath & "\NumeroChamados.txt"
Set rng = Selection
Open myFile For Output As #1
For i = 1 To rng.Rows.Count
For j = 1 To rng.Columns.Count
cellValue = rng.Cells(i, j).Value
If j = rng.Columns.Count Then
Print #1 , cellValue,
Else
Print #1 , cellValue,
End If
Next j
Next i
Close #1
End Sub