wildturkey
Board Regular
- Joined
- Feb 21, 2006
- Messages
- 189
- Office Version
- 365
- Platform
- Windows
Morning All
I have the following code which I've picked up from the internet and it all works great, however, and with little knowledge, Id like to change the ability to chose the range of rows to an absolute value of rows 28 to 60, so that only blank rows in this range are ignored when printing. Any help appreciated..
Sub Print_NonBlank_Rows()
'Updateby Extendoffice 20160704
Dim xStr As String
Dim xRg As Range
Dim xHideRg As Range
Dim xTxt As String
Dim I As Long
On Error Resume Next
If ActiveWindow.RangeSelection.Count > 1 Then
xTxt = ActiveWindow.RangeSelection.AddressLocal
Else
xTxt = ActiveSheet.UsedRange.AddressLocal
End If
Set xRg = Application.InputBox("please select the data range:", "Kutools for Excel", xTxt, , , , , 8)
If xRg Is Nothing Then Exit Sub
Application.ScreenUpdating = False
For I = 1 To xRg.Rows.Count
If Application.WorksheetFunction.CountA(xRg.Rows(I)) = 0 Then
If xHideRg Is Nothing Then
Set xHideRg = xRg.Rows(I)
Else
Set xHideRg = Union(xHideRg, xRg.Rows(I))
End If
End If
Next
xHideRg.EntireRow.Hidden = True
ActiveSheet.PrintOut Copies:=1
xHideRg.EntireRow.Hidden = False
Application.ScreenUpdating = True
End Sub
I have the following code which I've picked up from the internet and it all works great, however, and with little knowledge, Id like to change the ability to chose the range of rows to an absolute value of rows 28 to 60, so that only blank rows in this range are ignored when printing. Any help appreciated..
Sub Print_NonBlank_Rows()
'Updateby Extendoffice 20160704
Dim xStr As String
Dim xRg As Range
Dim xHideRg As Range
Dim xTxt As String
Dim I As Long
On Error Resume Next
If ActiveWindow.RangeSelection.Count > 1 Then
xTxt = ActiveWindow.RangeSelection.AddressLocal
Else
xTxt = ActiveSheet.UsedRange.AddressLocal
End If
Set xRg = Application.InputBox("please select the data range:", "Kutools for Excel", xTxt, , , , , 8)
If xRg Is Nothing Then Exit Sub
Application.ScreenUpdating = False
For I = 1 To xRg.Rows.Count
If Application.WorksheetFunction.CountA(xRg.Rows(I)) = 0 Then
If xHideRg Is Nothing Then
Set xHideRg = xRg.Rows(I)
Else
Set xHideRg = Union(xHideRg, xRg.Rows(I))
End If
End If
Next
xHideRg.EntireRow.Hidden = True
ActiveSheet.PrintOut Copies:=1
xHideRg.EntireRow.Hidden = False
Application.ScreenUpdating = True
End Sub