#1   Report Post  
Jeff Garrett
 
Posts: n/a
Default Macro help

Hi,
I am working on a macro in Excel 2003 Pro, and everytime I go to sort a
column of data. There are about 10 rows of data in about 200+ columns. I
can only get the macro to sort the column that I edited it with. How can I
create the macro, so each time I click on the first row of each column, click
the macro button I will assign to the toolbar, then that row will be sorted,
and do this for each column?

Any help at all would be greatly appreciated,
Jeff Garrett )
  #4   Report Post  
 
Posts: n/a
Default

posting your code would help.
Macros do not respond to mouse clicks or other forms of
input divices. the code replaces all these. mouse clicks
can trigger code to run but they can't be used as code
parameters.
you might try in the code to sort by Activecell but i
have never tried that and am not too sure it would work.

-----Original Message-----
Hi,
I am working on a macro in Excel 2003 Pro, and everytime

I go to sort a
column of data. There are about 10 rows of data in about

200+ columns. I
can only get the macro to sort the column that I edited

it with. How can I
create the macro, so each time I click on the first row

of each column, click
the macro button I will assign to the toolbar, then that

row will be sorted,
and do this for each column?

Any help at all would be greatly appreciated,
Jeff Garrett )
.

  #5   Report Post  
Jeff Garrett
 
Posts: n/a
Default

Sub Macro1()
Dim varColumn As String
Dim varNo As String
For varColumn = "A" To "IV"
varNo = varColumn & 1
Range([varNo]).Select
Application.CutCopyMode = False
Selection.Sort Key1:=Range(ActiveCell, ActiveCell.End(xlUp)).Select,
Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Next varColumn
End Sub


Basically, I want to go from Cell B1 to Cell IV1, and call this macro to
sort the column that is currently selected descendingly. It will be all
integers, some non-entries representing a 0. The whole reason to do a macro
is because there is like 200 entries in the worksheet.

Any and all suggestions are welcome.


  #7   Report Post  
Jeff Garrett
 
Posts: n/a
Default

Yes. Sort each column individually. Then, iterate over each column. Do I
have to dim lc, lr as variables? What kind though? String? Char?
  #8   Report Post  
Jeff Garrett
 
Posts: n/a
Default

Order1:=xlAscending
This means ascending order (lowest to highest) right? I want descending
order. So I put this:
Order1:=xlDescending

Correct?
  #10   Report Post  
Jeff Garrett
 
Posts: n/a
Default

That's worked Don. The only problem is it's doing too much. It should only
sort rows 2-12 inclusive, and this is what we last came up with:
lr = Cells(Rows.Count, i).End(xlUp).Row
This does too much. How do you do only sort the rows 2-12?


  #11   Report Post  
Don Guillett
 
Posts: n/a
Default

It is sorting row 2 - 12 if 12 is the last row with data. It would be 234 if
that was the last row with data. I thought you wanted it to be adaptable for
the amount of date in each column. If not, change to 12.....

--
Don Guillett
SalesAid Software

"Jeff Garrett" wrote in message
...
That's worked Don. The only problem is it's doing too much. It should

only
sort rows 2-12 inclusive, and this is what we last came up with:
lr = Cells(Rows.Count, i).End(xlUp).Row
This does too much. How do you do only sort the rows 2-12?



  #12   Report Post  
Jeff Garrett
 
Posts: n/a
Default

So lc must be the last row with acceptable data. It makes sense now.
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
select worksheet to run macro Hidaya Excel Discussion (Misc queries) 5 December 2nd 04 12:54 AM
Removing Unnecessary Macro Security Warnings o0icebox0o Excel Discussion (Misc queries) 1 November 30th 04 01:09 AM
search macro laprosa Excel Discussion (Misc queries) 0 November 26th 04 06:08 PM
Macro for Show/Hide Column Andy Excel Discussion (Misc queries) 2 November 26th 04 02:03 PM
This one is tricky....Macro to save file as cell value x in di Andy Excel Discussion (Misc queries) 4 November 26th 04 09:52 AM


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

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"