One more question - can I make the loop end after the last row with data?
Sub HideRows() BeginRow = 1 EndRow = 60 ChkCol = 4 ChkCol2 = 6 Sheets("27.09.-03.10.").Select Cells.Select Cells.EntireRow.AutoFit For RowCnt = BeginRow To EndRow If Cells(RowCnt, ChkCol).Value = 0 And Cells(RowCnt, ChkCol2).Value = 0 Then Cells(RowCnt, ChkCol).EntireRow.Hidden = True End If Next RowCnt End Sub
You should refer to solutions already given to you. Post #7 shows several ways to determine your EndRow dynamically. Options 1 and 2 seem perfectly suited. Apply one of those instead of hardcoding the EndRow value.
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
You have:
EndRow = 60
You substitute your hardcoded "60" with the technique I've shown you post #7.
EndRow = Cells.Find("*", Cells(Rows.Count, Columns.Count), SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
_________________
Microsoft MVP 2010 - Excel
Visit: Jerry Beaucaire's Excel Files & Macros
If you've been given good help, use theicon below to give reputation feedback, it is appreciated.
Always put your code between code tags. [CODE] your code here [/CODE]
“None of us is as good as all of us” - Ray Kroc
“Actually, I *am* a rocket scientist.” - JB (little ones count!)
Thank you very much! Solved!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks