Making a macro references relative

  • Thread starter Thread starter S.V.Proff
  • Start date Start date
S

S.V.Proff

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.)
 
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
 
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
 
Back
Top