Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Expanding VBA to include more than one column
Hi Group,
Please excuse a small repost of a question that I had on another group....it has to do with some VBA that will auto sort a list after a new item is typed in....I have 4 or 5 columns that have a drop down, with lists on a seperate page in the workbook....I have tried several things, but since I know nothing about what I'm doing, I got myself in just a little too deep...the code is this: Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Columns(1).Sort Key1:=Range("A1"), Order1:=xlAscending, _ Header:=xlGuess, OrderCustom:=1, _ MatchCase:=False, Orientation:=xlTopToBottom End Sub I can sort other lists by creating a new page for each list, but it adds a few pages to the workbook...can the code above be written to include a list in C1, E1, F1...etc, on the same sheet? I tried =Range("A1","C1", "E1", "F1"}, but I still just get column A to sort...any ideas will truly be appreciated...Thanks in Advance! Ken |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Expanding VBA to include more than one column
Give this a try:
Private Sub Worksheet_Change(ByVal Target As Range) Columns(Target.Column).Sort Key1:=Cells(1, Target.Column) _ , Order1:=xlAscending, Header:=xlGuess, OrderCustom:=1 _ , MatchCase:=False, Orientation:=xlTopToBottom End Sub You might need to put all that on one line if the attenuation bar isn't in there correctly. "Ken" wrote: Hi Group, Please excuse a small repost of a question that I had on another group....it has to do with some VBA that will auto sort a list after a new item is typed in....I have 4 or 5 columns that have a drop down, with lists on a seperate page in the workbook....I have tried several things, but since I know nothing about what I'm doing, I got myself in just a little too deep...the code is this: Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Columns(1).Sort Key1:=Range("A1"), Order1:=xlAscending, _ Header:=xlGuess, OrderCustom:=1, _ MatchCase:=False, Orientation:=xlTopToBottom End Sub I can sort other lists by creating a new page for each list, but it adds a few pages to the workbook...can the code above be written to include a list in C1, E1, F1...etc, on the same sheet? I tried =Range("A1","C1", "E1", "F1"}, but I still just get column A to sort...any ideas will truly be appreciated...Thanks in Advance! Ken |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Expanding VBA to include more than one column
On Oct 2, 6:31 pm, JLGWhiz wrote:
Give this a try: Private Sub Worksheet_Change(ByVal Target As Range) Columns(Target.Column).Sort Key1:=Cells(1, Target.Column) _ , Order1:=xlAscending, Header:=xlGuess, OrderCustom:=1 _ , MatchCase:=False, Orientation:=xlTopToBottom End Sub You might need to put all that on one line if the attenuation bar isn't in there correctly. "Ken" wrote: Hi Group, Please excuse a small repost of a question that I had on another group....it has to do with some VBA that will auto sort a list after a new item is typed in....I have 4 or 5 columns that have a drop down, with lists on a seperate page in the workbook....I have tried several things, but since I know nothing about what I'm doing, I got myself in just a little too deep...the code is this: Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Columns(1).Sort Key1:=Range("A1"), Order1:=xlAscending, _ Header:=xlGuess, OrderCustom:=1, _ MatchCase:=False, Orientation:=xlTopToBottom End Sub I can sort other lists by creating a new page for each list, but it adds a few pages to the workbook...can the code above be written to include a list in C1, E1, F1...etc, on the same sheet? I tried =Range("A1","C1", "E1", "F1"}, but I still just get column A to sort...any ideas will truly be appreciated...Thanks in Advance! Ken- Hide quoted text - - Show quoted text - JLGWhiz, That works perfectly on a test sheet.....I'll get that on my worksheet and give it a try, although I have no doubt it will work!! Thank you so much for your help! Ken |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can I expand a cell without expanding the whole column in Excel? | Excel Worksheet Functions | |||
Expanding Conditional Format Rule to entire Column | Excel Discussion (Misc queries) | |||
Expanding info on the top line without increasing the 1a column | Excel Worksheet Functions | |||
Expanding a data table to include an extra row | Excel Discussion (Misc queries) | |||
how do I expand a cell without expanding column | Excel Worksheet Functions |