How to get a macro to start in the right spot!

  • Thread starter Thread starter buzzled
  • Start date Start date
B

buzzled

I have a few macros that I use to input predetermined numbers in cells.

ie:
Sub testmacro()
Range("A3").Select
ActiveCell.FormulaR1C1 = "25"
Range("A4").Select
ActiveCell.FormulaR1C1 = "10"
Range("A5").Select
ActiveCell.FormulaR1C1 = "2"
Range("A6").Select
ActiveCell.FormulaR1C1 = "4"
Range("A7").Select
End Sub

The problem is that if a row is inserted above A3 then I want the macr
to start at A4. In other words I want it to start in the same relativ
cell.

Thank
 
You could give a name to each of your target cell, and that name woul
remain with the cell wherever it goes as a result of insertions, etc.
You can name your ranges in Excel by doing Insert>Name>Define, or yo
can simply select your target cell, type a range name in the Name bo
near the top left of the worksheet screen and (required) press Enter.

billy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Excel Macro Code Help 9
Excel Macro Help 4
find and findnext 1
Easy Macro 1
File Name changes with dates and Deleting Rows of Zeros 0
Long Macro 11
Target Macro 1
I'd like to modify mt Macro ... 9

Back
Top