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

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 411
Default Relative Range Selection

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
On Nov 1, 9:25 am, wrote:
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Relative Range Selection

One of many ways:

Sub showblock()
Set r = ActiveCell
Set r2 = Range(r, Range("U1"))
r2.Select
Selection.Copy
End Sub
--
Gary''s Student - gsnu200753


" wrote:

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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Relative Range Selection

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


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Relative Range Selection

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


wrote in message
ups.com...
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





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
Relative Range Selection & Paste Have_Data_Will_Travel Excel Discussion (Misc queries) 2 September 28th 09 11:58 PM
XL2K - Conditional Formatting relative to cell selection Lezh Excel Discussion (Misc queries) 3 December 31st 05 09:56 AM
Need to delete rows relative to selection ratchick Excel Programming 4 November 22nd 05 04:53 PM
Copy selection based on relative reference goofy11 Excel Programming 3 September 19th 05 05:57 PM
textbox selection to relative row? CAA Excel Programming 1 December 4th 03 01:21 AM


All times are GMT +1. The time now is 04:00 PM.

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

About Us

"It's about Microsoft Excel"