Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50090

Runtime error '9' Subscript out of range

$
0
0
Hi

I have copied my macro below.

While I am planning on recording a macro to do more than simply what is below I have played around with the macros for a couple of weeks now (I am a complete beginner) and are continuing to get the following error.

Runtime error '9' subscript out of range

I wish to import data lists that will be different everytime (but will directly import into the same columns) and sort this data alphabetically using a macro. It appears that because the length of the data list changes each time the macro is trying to reference a cell that doesn't really exist???

Any help would be greatly appreciated.

Thanks

Mick


Sub Pickingslip()
'
' Pickingslip Macro
'

'
Range("E13:H362").Select
ActiveWorkbook.Worksheets(" Patient History Report from 14").Sort.SortFields. _
Clear
ActiveWorkbook.Worksheets(" Patient History Report from 14").Sort.SortFields. _
Add Key:=Range("F13:F110"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets(" Patient History Report from 14").Sort
.SetRange Range("E13:H110")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub

Viewing all articles
Browse latest Browse all 50090

Trending Articles