ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Change range from cells to sheet? (https://www.excelbanter.com/excel-worksheet-functions/165158-change-range-cells-sheet.html)

JBW

Change range from cells to sheet?
 
Can I change the range from cells to sheet in following. I have problem when
data is bigger than range that macro currently selects, only sorts to 159th
line. ?

Range("A1:J159").Sort Key1:=Range("B3"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

Gary''s Student

Change range from cells to sheet?
 
n = Cells(Rows.Count, "J").End(xlUp).Row
s = "A1:J" & n
Range(s).Sort.........

Just replace the address in the Range with the string
--
Gary''s Student - gsnu200754


"JBW" wrote:

Can I change the range from cells to sheet in following. I have problem when
data is bigger than range that macro currently selects, only sorts to 159th
line. ?

Range("A1:J159").Sort Key1:=Range("B3"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com