ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   autosorting two attached columns (https://www.excelbanter.com/excel-programming/389516-autosorting-two-attached-columns.html)

Montana

autosorting two attached columns
 
I am creating an invoice with the following auto sort function:

Private Sub Worksheet_Change(ByVal Target As Range)
Range("d10:d28").Sort Key1:=Range("d10"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub

D column is product codes, but the C column is quantities. such as:
C D
4 95733
12 97003
1 55691

I need the quantities to move with the product codes when I enter new codes.
The D column is sorting correctly, but the C column quantities stay put. Any
help would be appreciated.

Dave Peterson

autosorting two attached columns
 
You're only sorting D10:D28.

Maybe you want to use C10:D28 or something else??????

Montana wrote:

I am creating an invoice with the following auto sort function:

Private Sub Worksheet_Change(ByVal Target As Range)
Range("d10:d28").Sort Key1:=Range("d10"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub

D column is product codes, but the C column is quantities. such as:
C D
4 95733
12 97003
1 55691

I need the quantities to move with the product codes when I enter new codes.
The D column is sorting correctly, but the C column quantities stay put. Any
help would be appreciated.


--

Dave Peterson

merjet

autosorting two attached columns
 
Change: Range("d10:d28").Sort
To: Range("c10:d28").Sort

Merjet


Montana

autosorting two attached columns
 
Yes, that did it. Much thanks.

"Dave Peterson" wrote:

You're only sorting D10:D28.

Maybe you want to use C10:D28 or something else??????

Montana wrote:

I am creating an invoice with the following auto sort function:

Private Sub Worksheet_Change(ByVal Target As Range)
Range("d10:d28").Sort Key1:=Range("d10"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub

D column is product codes, but the C column is quantities. such as:
C D
4 95733
12 97003
1 55691

I need the quantities to move with the product codes when I enter new codes.
The D column is sorting correctly, but the C column quantities stay put. Any
help would be appreciated.


--

Dave Peterson



All times are GMT +1. The time now is 12:26 AM.

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