I am trying to sort these three columns (**Sort By Col-2**) in excel using VBA. Top-left (Row number and Column number e.g. 1,1) and lowest-right cell (Row number and Column number e.g. 9,3) are known. Every cell contains the values of String type.

**Input:**

```
Col-1 Col-2 Col-3
P1 I1 XYZ 1 | XYZ 2 | XYZ 3
P8 I4 XYZ 26 | XYZ 27 | XYZ 28 | XYZ 29
P3 I2 XYZ 10 | XYZ 11 | XYZ 12
P6 I5 XYZ 19 | XYZ 20 | XYZ 21
P5 I2 XYZ 16 | XYZ17 | XYZ 18
P9 I1 XYZ 4 | XYZ 5 | XYZ 6
P7 I3 XYZ 22 | XYZ 23 | XYZ 24 | XYZ 25
P4 I2 XYZ 13 | XYZ14 | XYZ 15
P2 I2 XYZ 7 | XYZ 8 | XYZ 9
```

**Output:**

```
Col-1 Col-2 Col-3
P1 I1 XYZ 1 | XYZ 2 | XYZ 3
P9 I1 XYZ 4 | XYZ 5 | XYZ 6
P3 I2 XYZ 10 | XYZ 11 | XYZ 12
P5 I2 XYZ 16 | XYZ17 | XYZ 18
P4 I2 XYZ 13 | XYZ14 | XYZ 15
P2 I2 XYZ 7 | XYZ 8 | XYZ 9
P7 I3 XYZ 22 | XYZ 23 | XYZ 24 | XYZ 25
P8 I4 XYZ 26 | XYZ 27 | XYZ 28 | XYZ 29
P6 I5 XYZ 19 | XYZ 20 | XYZ 21
```

Macro recording gives me following code:

```
Sub SortingRecord()
'
' SortingRecord Macro
'
'
ActiveWorkbook.Worksheets("Sheet6").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet6").Sort.SortFields.Add Key:=Range("B1:B9"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet6").Sort
.SetRange Range("A1:C9")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
```

The problem is that I am new to VBA and not able to understand the meaning of many terms used in this code. So how to decide which statements are really necessary to program the solution.

The code I am doing doesn't need the worksheet number as I am running the macro on particular sheet so how to use sort method?

Please try to help me solving this problem. I do not want to get the range by selecting the cells so also want to use the cell numbers as given in the problem to make the program dynamic( As there might be change in the number of rows and columns).