autosorting two attached columns

G

Guest

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.
 
D

Dave Peterson

You're only sorting D10:D28.

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top