Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi I have a spreadsheet with macros assigned to command buttons that hide/unhide rows.....i also have a watched range (actually 2 ranges joined by a union) that colours cells depending on the value... What I want to be able to do is add a row or column and have the range extended automatically .....is this actually possible.... Also, the command button works by call a function (passing the row location as a variable) which calculates the next 5 lines and hides them...see the code below: Sub hideunhide(cellloc) Application.ScreenUpdating = False Dim cellstart, cellend As Long cellstart = cellloc + 1 cellend = cellloc + 5 Dim RangeSelect As Range Set RangeSelect = Range("b" & cellstart, "b" & cellend) RangeSelect.Select If Selection.EntireRow.Hidden = False Then Selection.EntireRow.Hidden = True Range("a" & cellstart).Select Application.ScreenUpdating = True Else RangeSelect.Select Selection.EntireRow.Hidden = False Range("a" & cellstart).Select Application.ScreenUpdating = True End If End Sub The only problem is that I have to manually enter the "cellloc" when calling the function i.e Private Sub CommandButton1_Click() hideunhide (5) End Sub This is fine but I literally have hundreds of buttons and when I have to insert one row it throws everything out from that line on... I am obviously a novice to Excel and VBA so please don't punish me!! Any suggestions on how I should go about it are welcome :-) one last thing...is there a way of using VBA to find out what cell or line a button is located??? either through it's properties or otherwise...this would go a long way to solving my problem!! Thanks Glenn -- glpabr ------------------------------------------------------------------------ glpabr's Profile: http://www.excelforum.com/member.php...o&userid=23967 View this thread: http://www.excelforum.com/showthread...hreadid=375894 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Dynamic Ranges | Excel Discussion (Misc queries) | |||
Dynamic Ranges using non-contiguous cells and dependent on a cell value | Excel Worksheet Functions | |||
Dynamic ranges | Charts and Charting in Excel | |||
Dynamic Ranges? | Excel Programming | |||
Dynamic Formulas with Dynamic Ranges | Excel Worksheet Functions |