Discussion Locked

Excel Navigation and copying

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have an Excel 97 worksheet with about 18 sheets in it. Every month I need to add a row at the bottom of each sheet with data that I have put in another sheet in the workbook.

Each sheet is not the same size so I need to go to the end of the data copy 2 cells and a bunch of formulas and then do the same thing for every sheet in this spreadsheet.

How can I specify "go to the bottom of the sheet" copy 2 cells and then copy formulas from above without actually specifying the range to copy to?

5 replies

by peyison

This code will move to the first blank cell after your data area and copy the formula from the cell above it:

'select an cell in your data area
Range("A1").Select

'move to the last row in the data area (this is based on the column you selected in step1)
Selection.End(xlDown).Select

'move one row down
ActiveCell.Offset(1, 0).Select

'copy the formula from the cell above
ActiveCell.FormulaR1C1 = ActiveCell.Offset(-1, 0).FormulaR1C1

If you want the relative formula, use .FormulaR1C1 - if you want the exact formula, use .Formula

Use ActiveCell.Offset(Row,Col).Select to move to another cell. To move to the cell to the right use ActiveCell.Offset(0,1).Select. To move three rows up and two columns to the right user ActiveCell.Offset(-3,2).Select.

Using these functions you should be able to do what you are looking for.

Hope this helps.

by sunilkk

Hi NicholasP,
You can write a macro through which you can
repeat your task every month.
I exactly could not get your need, are you want to write a macro or looking for Hot keys.
I suggest you to write a macro.
If you know a bit of VB programming you can
write a macro.
You can record a macro and start doing the
tasks as you normally do and then stop the macro. Then you can edit the macro in the
VBA Editor and customize to your needs.

Sunil

This discussion is closed to new replies.