View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.misc
big_mike big_mike is offline
external usenet poster
 
Posts: 3
Default Sorting within Rows

Jacob,

I am very new at macros. Thanks for the step by step. I tried your code
and received an error message. Syntax.

Sub CustomSort12() This line was background highlighted yellow.

Dim lngRow As Long
Dim lngLastRow As Long
lngLastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For lngRow = 2 To lngLastRow
Range("B" & lngRow & ":F" & lngRow).Sort Key1:=Range("B" & lngRow),
Orientation:=2 The above line was highlighted as if it
were selected.
Next

End Sub

What should I do?
--
big Mike


"Jacob Skaria" wrote:

Dear Mike

If you would like to try a macro find below.. Try using a test data..

Sub CustomSort12()

Dim lngRow As Long
Dim lngLastRow As Long
lngLastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For lngRow = 2 To lngLastRow
Range("B" & lngRow & ":F" & lngRow).Sort Key1:=Range("B" & lngRow),
Orientation:=2
Next

End Sub


Incase you are new to macros set the Security level to low/medium in
(Tools|Macro|Security). From workbook launch VBE using short-key Alt+F11.
From menu 'Insert' a module and paste the code. Save. Get back to Workbook.
Run the macro from Tools|Macro|Run <selected macro()

If this post helps click Yes
---------------
Jacob Skaria


"big_mike" wrote:

I have a huge spreadsheet that contains only 7 columns. I don't want to
change the information in the 1st and last colums. The data in the middle 5
columns are randomly entered (numbers) and I need to sort them from lowest to
highest keeping them in the rows they were entered in. The first column is
a date, all the rest are 1 or 2 digit numbers varying from 1 to 59. I only
want to change the order of each row to sort the middle 5 fields in low to
high sequence WITHOUT having to do each row separately. I already know how
to do that. I cannot find a way to conduct this operation enmass. Can
anyone help?
--
big Mike