I am new to all of the VB Code stuff, although i am getting to grips with it slowly, i am also going blind trying to understand it all !!
My issue is as follows:
I have recorded a Macro that will start at Cell C2, from there i keyed CNT+SHFT+DOWN ARROW to select all of the rows available (the reason i have used this is that the amount of rows will change from sheet to sheet, but i would like to use the same Macro)..
Anyway when i run this macro it always applied the same values of that recorded in the code DESPITE using the CNT+SHFT+DOWN ARROW to select the required rows.
The problem in the code appears to be here:
Where ranges E2:E15 & C2:C15 are defined, i still want to sort in this column but do not want it stop at 15...
Full code below - NB i have tried running this by selecting the required data and then naming the range in Excel, but this still fails !!! Grrr PLEASE HELP
My issue is as follows:
I have recorded a Macro that will start at Cell C2, from there i keyed CNT+SHFT+DOWN ARROW to select all of the rows available (the reason i have used this is that the amount of rows will change from sheet to sheet, but i would like to use the same Macro)..
Anyway when i run this macro it always applied the same values of that recorded in the code DESPITE using the CNT+SHFT+DOWN ARROW to select the required rows.
The problem in the code appears to be here:
Code:
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("E2:E15") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("C2:C15") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortTextAsNumbers
Full code below - NB i have tried running this by selecting the required data and then naming the range in Excel, but this still fails !!! Grrr PLEASE HELP
Code:
Sub Demo_RCD()
'
' Demo_RCD Macro
'
'
Range("C1").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("E2:E15") _
, SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("C2:C15") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortTextAsNumbers
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("A1:J15")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub