Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Danny
 
Posts: n/a
Default VBA, identify a range

I am writing a macro for sorting my worksheet. My macro would select a named
range, for instance the named range is A15. Then I go up one cell to A14 and
select A14 to E 14. The macro would read: Range("A14:E14").Select.

When I add more rows and go to the named range and go up one cell, the row
is no longer Row 14. How do I write the macro for this?
  #2   Report Post  
Bernie Deitrick
 
Posts: n/a
Default

Range("NamedRange").Offset(-1,0).Resize(1,5).Select

HTH,
Bernie
MS Excel MVP


"Danny" wrote in message
...
I am writing a macro for sorting my worksheet. My macro would select a named
range, for instance the named range is A15. Then I go up one cell to A14 and
select A14 to E 14. The macro would read: Range("A14:E14").Select.

When I add more rows and go to the named range and go up one cell, the row
is no longer Row 14. How do I write the macro for this?



  #3   Report Post  
Bob Phillips
 
Posts: n/a
Default

Set rng = Range("range_name").Offset(-1,0).Resize(1,5)
rng.Sort etc.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Danny" wrote in message
...
I am writing a macro for sorting my worksheet. My macro would select a

named
range, for instance the named range is A15. Then I go up one cell to A14

and
select A14 to E 14. The macro would read: Range("A14:E14").Select.

When I add more rows and go to the named range and go up one cell, the row
is no longer Row 14. How do I write the macro for this?



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
Match function...random search? Les Excel Worksheet Functions 10 July 28th 05 11:54 AM
How do I edit a Named Range using macro's behmer Excel Worksheet Functions 2 July 26th 05 09:02 PM
Identify the contents of column in a filtered range Jeff Excel Worksheet Functions 6 June 26th 05 11:25 PM
How to identify source or location of MAX_VALUE in range Phil Excel Worksheet Functions 5 March 7th 05 11:21 PM
Define a range based on another named range Basil Excel Worksheet Functions 2 February 21st 05 01:47 PM


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