Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Problem: When I write a macro that acts on certain cells, the macro fails to
act properly if I insert rows above those cells that are normally acted upon. I've tried to use both relative and absolute references, but when the row is inserted the original cell reference in Visual Basic is not changed, but remains the same. Question: Is there a way to write a macro so that when row or column is inserted the macro can go from any cell and find the correct cells to operate for the macro? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The short answer is no - there is no automatic adjustment of addresses used
in code. That said, most work around the column by analyzing the structure of the worksheet to identify the area they need to work. This would mean looking for unique attributes and values associated with the cells. Another approach is to use a defined name (insert =Name=Define) with refers to the upper left corner of the range (as an example). This would be adjusted by excel as rows are inserted and VBA could rely on that. -- Regards, Tom Ogilvy "bmorganh" wrote: Problem: When I write a macro that acts on certain cells, the macro fails to act properly if I insert rows above those cells that are normally acted upon. I've tried to use both relative and absolute references, but when the row is inserted the original cell reference in Visual Basic is not changed, but remains the same. Question: Is there a way to write a macro so that when row or column is inserted the macro can go from any cell and find the correct cells to operate for the macro? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use named ranges instead. For example say cell A7 is called _A7 and contains
a vlaue of XXXXX and you insert a row above if you refer to the named range it will now be A8 that now contains XXXXX. Mike "bmorganh" wrote: Problem: When I write a macro that acts on certain cells, the macro fails to act properly if I insert rows above those cells that are normally acted upon. I've tried to use both relative and absolute references, but when the row is inserted the original cell reference in Visual Basic is not changed, but remains the same. Question: Is there a way to write a macro so that when row or column is inserted the macro can go from any cell and find the correct cells to operate for the macro? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Formulas that reference cells that reference another cell | Excel Discussion (Misc queries) | |||
reference format Range(Cells(),Cells()) | Excel Programming | |||
Macro to Reference Column Next to Current Reference | Excel Discussion (Misc queries) | |||
How do I reference the last 3 cells in a row as cells are added | Excel Worksheet Functions | |||
How To: Macro Command To Reference Populated Cells Only | Excel Programming |