Relative Range Selection

  • Thread starter Thread starter dayton500
  • Start date Start date
D

dayton500

How do I make this range that I copy using my macro relative to the
cell I select. If I am at cell B4, I want it copy B4:U4.

Range("B1:U1").Select
Selection.copy

Thanks
 
In Excel 2000, on the macro recorder while the macro is running, there
is a button to select relative.

It looks like this:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 11/1/2007 by Dan Dungan
'

'
ActiveCell.Offset(-6, -3).Range("A1:B5").Select
End Sub

Dan
 
One of many ways:

Sub showblock()
Set r = ActiveCell
Set r2 = Range(r, Range("U1"))
r2.Select
Selection.Copy
End Sub
 
Activecell.Resize(,20).Copy

Unless you want to select any cell in the row, instead of just in column B:

Cells(Activecell.Row,2).Resize(,20).Copy

HTH,
Bernie
MS Excel MVP
 
One of many ways:

Except it doesn't work, always copying columns B through U, rows 1 through the activecell's row. I
think you meant something like

ActiveCell.Range("A1:T1").Copy

Bernie
 

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

Back
Top