Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Relative navigation in macro

I have a macro that I need to (1) insert a line, (2) copy/paste values only,
(3) copy/paste normal (contents of cell), and (4) delete a line. This
currently works only in the cell(s) where I created the macro. How can I
modify the macro so that it will execute anywhere (in different sheets, that
is) ? Here is the code:

Sub copypaste()
'
' copypaste Macro
'

'
Rows("526:526").Select
Selection.Insert Shift:=xlDown
Rows("525:525").Select
Selection.Copy
Rows("526:526").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("F527:H527").Select
Application.CutCopyMode = False
Selection.Copy
Range("F525").Select
ActiveSheet.Paste
Rows("527:527").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp
End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Relative navigation in macro

The code you have posted will operate on the active sheet. Did you want it to
operate relative to the active cell so that you could pick a row and perform
the operations relative to that row???
--
HTH...

Jim Thomlinson


"Steve Vincent" wrote:

I have a macro that I need to (1) insert a line, (2) copy/paste values only,
(3) copy/paste normal (contents of cell), and (4) delete a line. This
currently works only in the cell(s) where I created the macro. How can I
modify the macro so that it will execute anywhere (in different sheets, that
is) ? Here is the code:

Sub copypaste()
'
' copypaste Macro
'

'
Rows("526:526").Select
Selection.Insert Shift:=xlDown
Rows("525:525").Select
Selection.Copy
Rows("526:526").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("F527:H527").Select
Application.CutCopyMode = False
Selection.Copy
Range("F525").Select
ActiveSheet.Paste
Rows("527:527").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Relative navigation in macro

Jim,

Yes, I would like this to operate relative to the active cell. Sorry I
didn't clarify!



"Jim Thomlinson" wrote:

The code you have posted will operate on the active sheet. Did you want it to
operate relative to the active cell so that you could pick a row and perform
the operations relative to that row???
--
HTH...

Jim Thomlinson


"Steve Vincent" wrote:

I have a macro that I need to (1) insert a line, (2) copy/paste values only,
(3) copy/paste normal (contents of cell), and (4) delete a line. This
currently works only in the cell(s) where I created the macro. How can I
modify the macro so that it will execute anywhere (in different sheets, that
is) ? Here is the code:

Sub copypaste()
'
' copypaste Macro
'

'
Rows("526:526").Select
Selection.Insert Shift:=xlDown
Rows("525:525").Select
Selection.Copy
Rows("526:526").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("F527:H527").Select
Application.CutCopyMode = False
Selection.Copy
Range("F525").Select
ActiveSheet.Paste
Rows("527:527").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
The Relative Macro DanP Excel Discussion (Misc queries) 6 March 17th 09 02:58 PM
relative value in macro Janett Excel Discussion (Misc queries) 2 April 4th 06 05:42 PM
Data navigation macro retro88 Excel Programming 0 November 23rd 05 11:02 PM
navigation macro freezes cmarch[_2_] Excel Programming 1 September 17th 05 12:26 AM
relative ref. macro J.E. McGimpsey Excel Programming 0 July 28th 03 05:03 PM


All times are GMT +1. The time now is 09:03 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"