I want to hide rows and columns based on cell J5, if j5=5 then hide rows 14-18 from columnc-L,.
I am new to VBA and aprecaite your help
I want to hide rows and columns based on cell J5, if j5=5 then hide rows 14-18 from columnc-L,.
I am new to VBA and aprecaite your help
Try:
![]()
Sub Test() If Range("J5") = 5 Then Rows("14:18").Hidden = True Columns("C:L").Hidden = True End If End Sub
What I meant is if J5= i, then show rows from 14 to 14+i and hide the rest.
i=1,10
regards
Does this work?
![]()
Sub Test() Dim x As Integer x = Range("J5").Value Dim i As Integer Dim bottomB As Integer bottomB = Range("B" & Rows.Count).End(xlUp).Row On Error Resume Next For i = bottomB To 1 Step -1 If Rows(i).Row < 14 Or Rows(i).Row > 14 + x Then Rows(i).Hidden = True End If Next i Columns("C:L").Hidden = True End Sub
Last edited by Mumps1; 11-23-2012 at 03:41 PM.
Thanks a lot, done
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks