ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Hide an entire row - Not working (https://www.excelbanter.com/excel-programming/340075-hide-entire-row-not-working.html)

Mark

Hide an entire row - Not working
 
I am trying to use this code to hide a row. Am I using a property that
doesn't work? I do not get any error messages... I just do not get the
desired results.

If MyNewArchHide = True Then
For i = 1 To rng.Count
If cName(i) = "Transaction Date" Then
Set rng2 = .Range(.Cells(1, i), .Cells(2 ^ 16,
i).End(xlUp))
For j = rng2.Count To 2 Step -1
If .Cells(j, i).Value LowYear _
And .Cells(j, StatusColumn).Value = "Archive" Then
Rows(j).Select
HideSelection = True
End If
Next j
End If
Next i
End If

JNW

Hide an entire row - Not working
 
Try:
Selection.EntireColumn.Hidden = True

"Mark" wrote:

I am trying to use this code to hide a row. Am I using a property that
doesn't work? I do not get any error messages... I just do not get the
desired results.

If MyNewArchHide = True Then
For i = 1 To rng.Count
If cName(i) = "Transaction Date" Then
Set rng2 = .Range(.Cells(1, i), .Cells(2 ^ 16,
i).End(xlUp))
For j = rng2.Count To 2 Step -1
If .Cells(j, i).Value LowYear _
And .Cells(j, StatusColumn).Value = "Archive" Then
Rows(j).Select
HideSelection = True
End If
Next j
End If
Next i
End If


Dave Peterson

Hide an entire row - Not working
 
selection.entirerow.hidden = true
??

or just
rows(j).hidden = true

(and get rid of the .select line)

JNW wrote:

Try:
Selection.EntireColumn.Hidden = True

"Mark" wrote:

I am trying to use this code to hide a row. Am I using a property that
doesn't work? I do not get any error messages... I just do not get the
desired results.

If MyNewArchHide = True Then
For i = 1 To rng.Count
If cName(i) = "Transaction Date" Then
Set rng2 = .Range(.Cells(1, i), .Cells(2 ^ 16,
i).End(xlUp))
For j = rng2.Count To 2 Step -1
If .Cells(j, i).Value LowYear _
And .Cells(j, StatusColumn).Value = "Archive" Then
Rows(j).Select
HideSelection = True
End If
Next j
End If
Next i
End If


--

Dave Peterson


All times are GMT +1. The time now is 07:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com