Embarrassing Excel Macro Function

S

Serge

I wish I knew more about macros, I know someone will help me, please don't
laugh at me though :).

Here's my thing. I have supplied the small macro I have, IF i inserted 10
new rows in my worksheet the macro won't work anymore because it is looking
for the data in cell F15 and it isn't there anymoe because I have inserted
new lines, how do I telkl the macro to go to cell F25. Secondly I always need
the info in the original F15 cell, however I will not alwas add 10 rows,
maybe sometimes it will be 8, therefore I need the macro to go to the new
cell anfter I have inserted the rows.

Thanks in advance, since it is the 1st time I post here, I hope I wasn't too
long and was clear

Oh yes I use Office 2003.

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 28/12/2004 by Serge
'

'
Range("F15").Select
Selection.Copy
Range("A1").Select
ActiveSheet.Paste
End Sub



--
Dell 8200.
nVidia Ti 4200. 64mgs
RAM 512mgs.
P4, 2.26 Ghz.
OS, XP Home.
 
P

Patrick Molloy

use a named range perhaps?

name F15 say "MyData". when you insert rows, the name will follow the cell.

Sub Macro2()

Range("A1").Value = Range("Mydata").Value

End Sub

HTH
Patrick Molloy
Microsoft Excel MVP
 
S

Simon Shaw

In the excel sheet, assign a name to the source cell F15. This is found under
the Insert menu, select Names, then select Create. Give it a name like
'source_cell' and assign it to the cell F15. Then you can add a name for the
destination cell such as 'destination_cell'. Then your macro can be:

range("destination_cell").value = range("source_cell").value

you don't need to select, or use the copy/paste... if you simply want the
value to be updated to a new cell. if you want all the formatting, etc to be
brought over, you will have to use copy/paste or a more extensive macro.

This macro will work no mater where the named cells end up... you can insert
as many rows or columns as you like. You can even move one of the cells to a
new sheet in the workbook.
 

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

Top