ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Embarrassing Excel Macro Function (https://www.excelbanter.com/excel-programming/319670-embarrassing-excel-macro-function.html)

Serge

Embarrassing Excel Macro Function
 
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.

Patrick Molloy[_2_]

Embarrassing Excel Macro Function
 
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


"Serge" wrote:

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.


Don Guillett[_4_]

Embarrassing Excel Macro Function
 
try
range("a1")=range("f" & cells(rows.count,"F").end(xlup).row)

--
Don Guillett
SalesAid Software

"Serge" wrote in message
...
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.




Simon Shaw[_5_]

Embarrassing Excel Macro Function
 
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.



"Serge" wrote:

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.



All times are GMT +1. The time now is 06:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com