• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

end of the line

Hi all--

I built a macro to sort out a section of my spreadsheet (thanks for the help), what I could not figure out is how to have the macro put the cursor in the first blank cell in the first row. What do I have to do to go to the end of the line automatically:)?

LCD
 
Select the first blank cell in row 1:

Range("A1").End(xlToRight).Offset(0, 1).Select
 
Thanks Luke--

When I pasted your code below, I got an error. Please let me know your thoughts on fixing it.


Range("A4:J156").Select

ActiveWindow.SmallScroll Down:=-165

Range("A2:J338").Select

ActiveWindow.SmallScroll Down:=-330

ActiveWorkbook.Worksheets("Rotary").Sort.SortFields.Clear

ActiveWorkbook.Worksheets("Rotary").Sort.SortFields.Add Key:=Range("A3:A338") _

, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal

ActiveWorkbook.Worksheets("Rotary").Sort.SortFields.Add Key:=Range("B3:B338") _

, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal

ActiveWorkbook.Worksheets("Rotary").Sort.SortFields.Add Key:=Range("E3:E338") _

, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal

With ActiveWorkbook.Worksheets("Rotary").Sort

.SetRange Range("A2:J338")

.Header = xlYes

.MatchCase = False

.Orientation = xlTopToBottom

.SortMethod = xlPinYin

.Apply

End With

Range("A1").End(xlToRight).Offset(0, 1).Select


End Sub
 
Thanks for the help Luke, but when I put it in the below code, I get the debugger window and it highlights that line of text. Did I put it in the wrong place?

LCD


Sub rotary()

'

' rotary Macro

'


'

Range("A4:J156").Select

ActiveWindow.SmallScroll Down:=-165

Range("A2:J338").Select

ActiveWindow.SmallScroll Down:=-330

ActiveWorkbook.Worksheets("Rotary").Sort.SortFields.Clear

ActiveWorkbook.Worksheets("Rotary").Sort.SortFields.Add Key:=Range("A3:A338") _

, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal

ActiveWorkbook.Worksheets("Rotary").Sort.SortFields.Add Key:=Range("B3:B338") _

, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal

ActiveWorkbook.Worksheets("Rotary").Sort.SortFields.Add Key:=Range("E3:E338") _

, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal

With ActiveWorkbook.Worksheets("Rotary").Sort

.SetRange Range("A2:J338")

.Header = xlYes

.MatchCase = False

.Orientation = xlTopToBottom

.SortMethod = xlPinYin

.Apply

End With

Range("A1").End(xlToRight).Offset(0, 1).Select

End Sub
 
Back
Top