ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   hide rows when the cell is #VALUE! (https://www.excelbanter.com/excel-worksheet-functions/76523-hide-rows-when-cell-value.html)

barkiny

hide rows when the cell is #VALUE!
 

i want to write a macro when a cell gives error then hide the entire row
(
#VALUE! )

Sub HideRows()
BeginRow = 1
EndRow = 10
ChkCol = 2

For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value = "-" Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
Else
Cells(RowCnt, ChkCol).EntireRow.Hidden = False
End If
Next RowCnt
End Sub

thanks in advance


--
barkiny
------------------------------------------------------------------------
barkiny's Profile: http://www.excelforum.com/member.php...o&userid=20397
View this thread: http://www.excelforum.com/showthread...hreadid=521016


Otto Moehrbach

hide rows when the cell is #VALUE!
 
One way:
Use something like:
If IsError(Cells(RowCnt, ChkCol).Value) Then
HTH Otto
"barkiny" wrote in
message ...

i want to write a macro when a cell gives error then hide the entire row
(
#VALUE! )

Sub HideRows()
BeginRow = 1
EndRow = 10
ChkCol = 2

For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value = "-" Then
Cells(RowCnt, ChkCol).EntireRow.Hidden = True
Else
Cells(RowCnt, ChkCol).EntireRow.Hidden = False
End If
Next RowCnt
End Sub

thanks in advance


--
barkiny
------------------------------------------------------------------------
barkiny's Profile:
http://www.excelforum.com/member.php...o&userid=20397
View this thread: http://www.excelforum.com/showthread...hreadid=521016





All times are GMT +1. The time now is 01:19 PM.

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