Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I expand a cell without expanding the whole column in Excel? Monica Excel Worksheet Functions 1 July 24th 09 11:42 PM
Expanding Conditional Format Rule to entire Column KKD Excel Discussion (Misc queries) 1 May 27th 09 07:58 PM
Expanding info on the top line without increasing the 1a column SILVERTHORNE Excel Worksheet Functions 3 October 8th 08 10:48 PM
Expanding a data table to include an extra row HRobinson Excel Discussion (Misc queries) 1 July 7th 08 09:20 AM
how do I expand a cell without expanding column ashaback Excel Worksheet Functions 1 March 23rd 06 05:25 PM


All times are GMT +1. The time now is 02:36 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"