Hey all,
Right, I have a row of Title, Name, Telephone Number etc and what I want to do is organise the fields below these titles to appear in order (Mr first, Mrs second, Ms third, Miss last) but also, that it organises all the information within the corresponding fields as well. But I'm not sure how to link this VB code to my macro so when I click the button, it organises.
I think I have my code ok, but I wouldn't be suprised if I went totally off mark here as VB isn't really my fort'e 
Code:
Dim rowVa As Integer, colVa As String
rowVa = Selection.Row
colVa = Selection.Column
colVa = GetExcelColumn(Selection.Column)
If Cells(rowVa, colVa) = "Title" Then
Range(colVa & "2", colVa & "5").Select
' here you can introduce a function to get the no of last cell and include it in place of 5
Selection.Sort Key1:=Range(colVa & "2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End If
End Sub
Function GetExcelColumn(ByVal iCellNo As Integer) As String
Dim iBeg, iEnd As Integer
' If 1-26, then this is an easy conversion
If iCellNo < 27 Then
GetExcelColumn = Chr$(iCellNo + 64)
Else
' Now we have to account for AA-ZZ
iBeg = iCellNo \ 26 ' Get the first letter
iEnd = iCellNo Mod 26 ' Get the second letter
If iEnd = 0 Then
' If iEnd is 0, then it is Z, which should be 26
iEnd = 26
'** you need to subtract 1 from the initial letter otherwise your lettering will be the next letter in the alphabet
iBeg = iBeg - 1
End If
GetExcelColumn = Chr$(iBeg + 64) & Chr$(iEnd + 64)
End If
End Function
Any suggestions greatly appreciated
Bookmarks