Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 39
Default Relative reference? in macro

I have a list of client names and locations in columns A and B respectively,
up to row 100. I recorded a macro that resorts the list by client name after
I add new data. My new data would be in rows 101 to 105.

Part of the code goes:
With ActiveWorkbook.Worksheets("ClientNames").Sort
.SetRange Range("A1:B100")
. Header . . .
. MatchCase
. etc

When recording the macro, here's how I selected the sort range--in tab
ClientNames, I went to cell A1 then clicked on the Select Current Range icon.
Did the sort and clicked on the Stop Recording button. I tried recording this
several times, clicking on the Use Relative Reference button at various
times. Didn't work. The macro limited the sort to rows 1 to 100 when I needed
it to sort rows 1 to 105.

I tried a different approach at selecting the sort range by going to cell
A1, then hitting the End and Downarrow keys to get to the last entry on the
list before clicking on the Select Current Range icon. Didn't work either.

This seems simple enough but I'm stumped. How can I make this work.

Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,441
Default Relative reference? in macro

TRYING,

Replace

Range("A1:B100")
with

Range(Range("A1"),Range("B1").End(xlDown))

HTH,
Bernie
MS Excel MVP

"TRYING" wrote in message
...
I have a list of client names and locations in columns A and B
respectively,
up to row 100. I recorded a macro that resorts the list by client name
after
I add new data. My new data would be in rows 101 to 105.

Part of the code goes:
With ActiveWorkbook.Worksheets("ClientNames").Sort
.SetRange Range("A1:B100")
. Header . . .
. MatchCase
. etc

When recording the macro, here's how I selected the sort range--in tab
ClientNames, I went to cell A1 then clicked on the Select Current Range
icon.
Did the sort and clicked on the Stop Recording button. I tried recording
this
several times, clicking on the Use Relative Reference button at various
times. Didn't work. The macro limited the sort to rows 1 to 100 when I
needed
it to sort rows 1 to 105.

I tried a different approach at selecting the sort range by going to cell
A1, then hitting the End and Downarrow keys to get to the last entry on
the
list before clicking on the Select Current Range icon. Didn't work either.

This seems simple enough but I'm stumped. How can I make this work.

Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 39
Default Relative reference? in macro

Forgot to mention that I'm using Excel 2007.


"TRYING" wrote:

I have a list of client names and locations in columns A and B respectively,
up to row 100. I recorded a macro that resorts the list by client name after
I add new data. My new data would be in rows 101 to 105.

Part of the code goes:
With ActiveWorkbook.Worksheets("ClientNames").Sort
.SetRange Range("A1:B100")
. Header . . .
. MatchCase
. etc

When recording the macro, here's how I selected the sort range--in tab
ClientNames, I went to cell A1 then clicked on the Select Current Range icon.
Did the sort and clicked on the Stop Recording button. I tried recording this
several times, clicking on the Use Relative Reference button at various
times. Didn't work. The macro limited the sort to rows 1 to 100 when I needed
it to sort rows 1 to 105.

I tried a different approach at selecting the sort range by going to cell
A1, then hitting the End and Downarrow keys to get to the last entry on the
list before clicking on the Select Current Range icon. Didn't work either.

This seems simple enough but I'm stumped. How can I make this work.

Thanks.

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 39
Default Relative reference? in macro

Thanks, Bernie. It worked.

I also tried another solution. I edited the code and replaced "B100" with
"B1000" since I figure it would take a really long time before we reach row
1000. This one works too.

But your solution is exactly what I was trying to do, not just result-wise
but process-wise.

I'm just curious why I couldn't make my first approach work using macro
recording.

"Bernie Deitrick" wrote:

TRYING,

Replace

Range("A1:B100")
with

Range(Range("A1"),Range("B1").End(xlDown))

HTH,
Bernie
MS Excel MVP

"TRYING" wrote in message
...
I have a list of client names and locations in columns A and B
respectively,
up to row 100. I recorded a macro that resorts the list by client name
after
I add new data. My new data would be in rows 101 to 105.

Part of the code goes:
With ActiveWorkbook.Worksheets("ClientNames").Sort
.SetRange Range("A1:B100")
. Header . . .
. MatchCase
. etc

When recording the macro, here's how I selected the sort range--in tab
ClientNames, I went to cell A1 then clicked on the Select Current Range
icon.
Did the sort and clicked on the Stop Recording button. I tried recording
this
several times, clicking on the Use Relative Reference button at various
times. Didn't work. The macro limited the sort to rows 1 to 100 when I
needed
it to sort rows 1 to 105.

I tried a different approach at selecting the sort range by going to cell
A1, then hitting the End and Downarrow keys to get to the last entry on
the
list before clicking on the Select Current Range icon. Didn't work either.

This seems simple enough but I'm stumped. How can I make this work.

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
Macro relative reference toolbar disappeared Fred Excel Worksheet Functions 1 December 7th 06 03:39 AM
Using an offset formula for the reference in a relative reference Cuda Excel Worksheet Functions 6 November 15th 06 05:12 PM
how do I change macro relative reference? no stop recording tool G Excel Discussion (Misc queries) 1 November 11th 06 08:09 PM
Using relative reference in macro Bas Excel Discussion (Misc queries) 0 March 23rd 06 12:11 PM
Recording new excel macro, relative reference button doesn't show Dano New Users to Excel 3 August 23rd 05 07:36 PM


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