code for sorting

  • Thread starter Thread starter wessj
  • Start date Start date
W

wessj

I can't get this to do what I want for the life of me...

Basically, I want a block of VB code that will sort the
currently selected set of cells in ascending order by
column B then by column C with no header row.

I want to select the group of cells, then click a button
on the tool bar that performs the sort as described. I
know a little VB but obviously not enough to figure this
out...
 
I tried doing the macro, but it hardcoded in the cells
that I had selected. I wasn't sure how to sort whatever's
current...
 
"Selection.Sort (etc.)" causes Sort to operate on the currently selected
range.
"Selection.Cells(1)" stands for the first (top-left) cell in the currently
selected range.
"Selection.Cells(2)" stands for the cell "next to" the first (top-left) cell
in the currently selected range. This will be the next cell to the right, if
the selection is more than one cell wide, or it will be the next cell down
if the selection is one cell wide (but more than two cells high). If the
selection is only one cell, using "Selection.Cells(2)" will raise an error.
 
Back
Top