Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi, In Excel I have named ranges, for example rows 13:23 are a named rang called "RijenFundering". When I select a cell in row 23 and use th macro below to insert a row, then the empty row will be row 24. That i outside the named range. I also have a macro (see the second one below) to delete a row, bu with this macro I cannot delete row 24, because it is outside the name range. I tried something like Range("RijenFundering" + 1) but I get a error then. How should one of these macros be rewritten, so I am able to delete ro 24? Thank in advance for helping me! Sub InsertRows() If Intersect(ActiveCell, Union(Range("RijenFundering"), _ Range("RijenBeganeGrondvloer"), Range("RijenMetselwerkenMinPeil") _ Range("RijenBetonskeletBetonvloer") Range("RijenKZSWandBetonvloer"), _ Range("RijenPrefabBetonBuitenspouwblad") Range("RijenStaalconstructie"), _ Range("RijenStaalwerk"), Range("RijenMetselwerken"), _ Range("RijenGevelsluitendeElementen") Range("RijenDakconstructie"), _ Range("RijenPrefabElementen"), Range("RijenDiversen"))) Is Nothin Then MsgBox "U kunt hier geen rij invoegen" Else Call InsertRows1 End If End Sub Private Sub InsertRows1() Application.ScreenUpdating = False ActiveCell.Offset(1, 0).EntireRow.Insert ActiveCell.EntireRow.Copy ActiveCell.Offset(1, 0).EntireRow Selection.Offset(1).EntireRow.SpecialCells(xlConst ants).ClearContents End Sub -------------------------------------------------------------------------- Sub DeleteRows() If Intersect(ActiveCell, Union(Range("RijenFundering"), _ Range("RijenBeganeGrondvloer"), Range("RijenMetselwerkenMinPeil") _ Range("RijenBetonskeletBetonvloer") Range("RijenKZSWandBetonvloer"), _ Range("RijenPrefabBetonBuitenspouwblad") Range("RijenStaalconstructie"), _ Range("RijenStaalwerk"), Range("RijenMetselwerken"), _ Range("RijenGevelsluitendeElementen") Range("RijenDakconstructie"), _ Range("RijenPrefabElementen"), Range("RijenDiversen"))) Is Nothin Then MsgBox "U kunt deze rij niet verwijderen" Else Call DeleteRows1 End If End Sub Private Sub DeleteRows1() Application.ScreenUpdating = False ActiveCell.EntireRow.Delete End Su -- leonida ----------------------------------------------------------------------- leonidas's Profile: http://www.excelforum.com/member.php...fo&userid=3537 View this thread: http://www.excelforum.com/showthread.php?threadid=55489 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Hpw do I delete multiple empty rows found between filled rows? | Excel Worksheet Functions | |||
Cut filtered rows, paste into next empty row of new sheet, and delete cut rows | Excel Worksheet Functions | |||
Delete rows with numeric values, leave rows with text | Excel Programming | |||
How to delete rows when List toolbar's "delete" isnt highlighted? | Excel Worksheet Functions | |||
Delete every 3rd row, then delete rows 2-7, move info f/every 2nd row up one to the end and delete the row below | Excel Programming |