Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a macro with the following line:
Range("A1:G1024").Sort Key1:=Range("E2"), Is there a way to code it so that whenever I add a new item I don't have to continually edit the macro, and change the end range value to accommodate the newly inserted item? -- Regards Michael Koerner |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
Set SortRange=Range("A1" ,Range("G" & Rows.Count).end(xlup)) SortRange.Sort Key1:=Range("E2") Hopes this helps. Per "Michael Koerner" skrev i meddelelsen ... I have a macro with the following line: Range("A1:G1024").Sort Key1:=Range("E2"), Is there a way to code it so that whenever I add a new item I don't have to continually edit the macro, and change the end range value to accommodate the newly inserted item? -- Regards Michael Koerner |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
lastrow = Cells(Rows.Count, "G").End(xlUp).Row Range("A1:G" & lastrow).Sort Key1:=Range("E2") Mike "Michael Koerner" wrote: I have a macro with the following line: Range("A1:G1024").Sort Key1:=Range("E2"), Is there a way to code it so that whenever I add a new item I don't have to continually edit the macro, and change the end range value to accommodate the newly inserted item? -- Regards Michael Koerner |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Depending on your SortFields, you may be able to get away with this if
Column H:H is clear. The idea being that a single cell tells Excel to use the "Current Region." Sub Demo() [E1].Sort [E1] End Sub = = = Dana DeLouis Michael Koerner wrote: I have a macro with the following line: Range("A1:G1024").Sort Key1:=Range("E2"), Is there a way to code it so that whenever I add a new item I don't have to continually edit the macro, and change the end range value to accommodate the newly inserted item? |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, will try it out.
-- Regards Michael Koerner "Per Jessen" wrote in message ... Hi Set SortRange=Range("A1" ,Range("G" & Rows.Count).end(xlup)) SortRange.Sort Key1:=Range("E2") Hopes this helps. Per "Michael Koerner" skrev i meddelelsen ... I have a macro with the following line: Range("A1:G1024").Sort Key1:=Range("E2"), Is there a way to code it so that whenever I add a new item I don't have to continually edit the macro, and change the end range value to accommodate the newly inserted item? -- Regards Michael Koerner |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, will try it out.
-- Regards Michael Koerner "Mike H" wrote in message ... Hi, lastrow = Cells(Rows.Count, "G").End(xlUp).Row Range("A1:G" & lastrow).Sort Key1:=Range("E2") Mike "Michael Koerner" wrote: I have a macro with the following line: Range("A1:G1024").Sort Key1:=Range("E2"), Is there a way to code it so that whenever I add a new item I don't have to continually edit the macro, and change the end range value to accommodate the newly inserted item? -- Regards Michael Koerner |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|