Home |
Search |
Today's Posts |
#6
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
hi,
yes you are right, the code did not update. but on the sheet the variable which was set prior to add row shifted to d11 after the row was added. to test do this dim r as range set r = range("D10") r.select rows("6:6").insert shift:=xldown r.select msgbox r.address you will set that though set at D10 prior to add row, it is now selecting D11 and the variable is now D11 after add row. Regards FSt1 "Adam" wrote: I'm still not sure what I'm supposed to do. I tried the code you provided in VB, but when I inserted a row the code: set r = range("D10") did not update to: set r = range("D11"). Forgetting about auto-updating the macro, is there any way to select a cell by the variable name instead of the cell location? I tried Range("var_name").Select but that does not work. Thanks, Adam "FSt1" wrote: hi you might try variables dim r as range set r = range("D10") if you add rows above D10, the variable should shift down if that is what you are trying to achive. regards FSt1 "Adam" wrote: Hi, When I insert a row after I have recorded a macro, the macro stops referring to the correct cells. To fix this, I tried naming all the cells variables and having the macro refer to the variable names instead of the cell location (ie. A1). So instead of: Range("A1").Select Selection.Copy I tried: Range("pop1d").Select Selection.Copy but I get an error message that says "select method of range class failed". What is the correct way to refer to variable names in visual basic? Also, is there any other way to have visual basic auto-update and refer to the correct cells if I were to insert a row after recording the macro? Thanks, Adam |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Using formulas to select cells (Ex: Select every nth cell in a col | Excel Discussion (Misc queries) | |||
Use a Variable to select a range | Excel Discussion (Misc queries) | |||
Select one variable from a list of variables by clicking one cell | Excel Discussion (Misc queries) | |||
Excel 2003: In a Macro,how to select a variable row length table | Excel Discussion (Misc queries) | |||
Range("C9:V9").Select ==> changing the 9 to a variable | Excel Worksheet Functions |