Relative movements within macros
I am trying to program some macros to do some automatic formatting of some
imported information. On any single run of the similar information the
formatting works quite well. However, if there are added rows or columns,
some parts seem to screw up.
for example:
A series of numbers currently are in cells C8:C18 and the cursor is
currently on C8. From the keyboard I wish to hit Shift-End-Down Arrow to
select the column to the end and then hit Shift-Down Arrow twice to go to the
second line down leaving a blank line but selecting all the cells between
C8:C18. I have relative referencing active when I started recording.
So at this point I have cells C8:C20 highlighted. This works as long as the
column only goes from C8 to C18. However, I cannot control this. Sometimes
it may be the data starts at C8 and extends to C22 and I want to select the
cells C8:C24 without having to know the extra rows exist.
The macros keep recording
Range(Selection, Selection.End(xlDown)).Select
ActiveCell.Range("A1:A13").Select
but I don't want it to defaul to A13 all the time because it could be longer
or even shorter.
Anyone have any ideas? I can't find anything on the MS website using
searches like cursor move or moving cursor, etc.
Ultimately I want to sum the column and have the sum show in the last cell
selected, then copy that formula for all the remainingg columns (the number
of which I will not know so I was going to use the keyboard commands to Copy
the formula, go back up two lines, End Right Arrow to get to the last column,
move down two rows and select the cells back to the original and paste. Hope
this makes sense. TIA rasinc
|