LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
 
Posts: n/a
Default need help righting script to sort rows alphabetically then seperate them to line up

Hello, can anybody please help me I am new to script righting and was
trying to figure out how to sort my table.

I have a table that is at least 800 rows and about 5 columns wide.
short example of a row would be

ROW column B column C column D column E
1 j1-2 u13-2 j12-4 e3-6
2 e6-34 u12-2


So I found this script (at bottom) that somebody did for somebody else
that sorts each row individually alphabetically and it doesn't touch
column A which is what I need but every time I have to edit the script
with how deep and how wide it is, is there a way so that after you run
the script it will prompt you how deep and wide you want it. But also I
still need it to seperate each column so no one has more than one
starting letter. example after it is sorted it would look like this:

ROW column B column C column D column E
1 j1-2 j12-4 e3-6 u13-2
2 e6-34 u12-2

Some have 3 "j's" some have 3 "u's" its somewhat random. is there any
way to do this. Right now with the script I found after it alphabatize
them. I would then have to sort the columns alphabetically then
manually go down the list and shift over the remaining columns to the
first column with that letter. then resort and continue this tell there
is no column with more then one starting letter (except the first). I
would just do it manually except I have to do this a couple times and
each one can get around 800-900 rows deep. Thanks in advance for the
help.



Sub SortRows()


Dim r As Long
Dim lrow As Long


Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
lrow = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Row


'Make the r = 3 whatever the first row of data you want to sort on is.
'The Cells(r, 2) means your data starts in Col 2 or Col B - adjust as
necessary
'The resize(1, 4) expands the range to 1 cell deep by 4 cells wide


For r = 3 To lrow
With Cells(r, 2).Resize(1, 4)
.Sort Key1:=Cells(r, 1), Order1:=xlAscending, Header:=xlGuess,
_
Orientation:=xlLeftToRight, DataOption1:=xlSortNormal
End With
Next r


Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic


End Sub

 
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
Insert rows based on specific value bob Excel Worksheet Functions 6 February 29th 08 07:11 PM
My rows are off by one row, ie. data on line 10 should line up wi. lindamari New Users to Excel 1 April 19th 05 04:25 PM
Insert rows Mr. G. Excel Worksheet Functions 3 March 31st 05 03:49 AM
HELP! How do you--> Lock a set of rows but also link worksheets to FRUSTRATED Excel Discussion (Misc queries) 6 December 29th 04 10:05 PM
Can Excel sort rows by color? Grant Excel Discussion (Misc queries) 2 December 16th 04 02:00 PM


All times are GMT +1. The time now is 10:04 PM.

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

About Us

"It's about Microsoft Excel"