Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Making a macro references relative

Hello All:

I have been away from using Macros for some time and I am finding that
I have forgotten how to make refereces to cells relative in a macro.

On top of this, I discovered I do not have help files...

I have the following:

Sub k()
'
' k Macro
'

'
ActiveSheet.Paste
Range("V245:AF245").Select
Application.CutCopyMode = False
Selection.Copy
Range("I243").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
End Sub

How do I make references relative to the current cell the cursor is
in?

Thanks!

Sam
(Please post your replies here. My e-mail address is spam proofed.)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Making a macro references relative

Sam,

Below are two macros that perhaps will give you some ideas.

'-------
Sub test23()
Dim srcRng As Range, selRng As Range
Set selRng = Selection
Set srcRng = Range("V245:AF245")
srcRng.Copy
srcRng.Offset(-2, -13).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
selRng.Select
End Sub
'-------
Sub test24()
Selection.Copy
Selection.Offset(-2, -13).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
End Sub
'-------

HTH
Anders Silvén

"S.V.Proff" skrev i meddelandet om...
Hello All:

I have been away from using Macros for some time and I am finding that
I have forgotten how to make refereces to cells relative in a macro.

On top of this, I discovered I do not have help files...

I have the following:

Sub k()
'
' k Macro
'

'
ActiveSheet.Paste
Range("V245:AF245").Select
Application.CutCopyMode = False
Selection.Copy
Range("I243").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
End Sub

How do I make references relative to the current cell the cursor is
in?

Thanks!

Sam
(Please post your replies here. My e-mail address is spam proofed.)

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Making a macro references relative

ActiveCell.offset(10,15).Resize(20,10)

offset(row offset, column offset)

offset(0,0) is the base cell.

from the immediate window:
Range("A1").Select
? ActiveCell.offset(10,15).Resize(20,10).Address
$P$11:$Y$30


--
Regards,
Tom Ogilvy

"S.V.Proff" wrote in message
om...
Hello All:

I have been away from using Macros for some time and I am finding that
I have forgotten how to make refereces to cells relative in a macro.

On top of this, I discovered I do not have help files...

I have the following:

Sub k()
'
' k Macro
'

'
ActiveSheet.Paste
Range("V245:AF245").Select
Application.CutCopyMode = False
Selection.Copy
Range("I243").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
End Sub

How do I make references relative to the current cell the cursor is
in?

Thanks!

Sam
(Please post your replies here. My e-mail address is spam proofed.)



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
Macro using relative references warp9 Excel Worksheet Functions 5 October 21st 08 04:21 AM
convert relative cell references to absolute cell references via amacro? Dave F[_2_] Excel Discussion (Misc queries) 1 May 15th 08 04:43 PM
Help with converting a block of cells with Absolute and mixed references to relative references Vulcan Excel Worksheet Functions 3 December 13th 07 11:43 PM
macro vba relative references aut1jlt Excel Worksheet Functions 0 April 20th 05 06:13 PM
Making the Sheet a relative value? AuMiQuinn Excel Worksheet Functions 4 January 5th 05 07:38 PM


All times are GMT +1. The time now is 08:21 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"