M
Microsoft Forum
Hi all,
I have the following program:
*****************************
Function IsBlankRange(Rng As Range) As Boolean
Dim r As Range
IsBlankRange = True
For Each r In Rng
If Not IsEmpty(r) Then
IsBlankRange = False
Exit Function
End If
Next
End Function
Sub TableOnly()
Dim tbl As Range
Dim IsTopRowBlank As Boolean
Dim IsBtmRowBlank As Boolean
Dim IsLeftColBlank As Boolean
Dim IsRightColBlank As Boolean
Dim T As Range
Set T = ActiveCell.CurrentRegion
If IsBlankRange(T.Columns(1).Cells) Then IsLeftColBlank = True
If IsBlankRange(T.Rows(1).Cells) Then IsTopRowBlank = True
If IsBlankRange(T.Columns(T.Columns.Count).Cells) Then IsRightColBlank =
True
If IsBlankRange(T.Rows(T.Rows.Count).Cells) Then IsBtmRowBlank = True
End Sub
**************************************
But if I delete the ".Cells" in the last four lines (excluding the "End Sub"
line) of the program, it won't work. Why is that? Seems to me that
"T.Rows(i)" is just a range to me. Please advise.
Frederick Chow
Hong Kong.
I have the following program:
*****************************
Function IsBlankRange(Rng As Range) As Boolean
Dim r As Range
IsBlankRange = True
For Each r In Rng
If Not IsEmpty(r) Then
IsBlankRange = False
Exit Function
End If
Next
End Function
Sub TableOnly()
Dim tbl As Range
Dim IsTopRowBlank As Boolean
Dim IsBtmRowBlank As Boolean
Dim IsLeftColBlank As Boolean
Dim IsRightColBlank As Boolean
Dim T As Range
Set T = ActiveCell.CurrentRegion
If IsBlankRange(T.Columns(1).Cells) Then IsLeftColBlank = True
If IsBlankRange(T.Rows(1).Cells) Then IsTopRowBlank = True
If IsBlankRange(T.Columns(T.Columns.Count).Cells) Then IsRightColBlank =
True
If IsBlankRange(T.Rows(T.Rows.Count).Cells) Then IsBtmRowBlank = True
End Sub
**************************************
But if I delete the ".Cells" in the last four lines (excluding the "End Sub"
line) of the program, it won't work. Why is that? Seems to me that
"T.Rows(i)" is just a range to me. Please advise.
Frederick Chow
Hong Kong.