jmutsche
12-09-2013, 02:01 PM
Sub Macro3()
Dim myrng As Range
With ActiveSheet
If .AutoFilterMode Then
.ShowAllData
End If
End With
ActiveSheet.AutoFilter.Sort.SortFields. _
Clear
ActiveSheet.AutoFilter.Sort.SortFields. _
Add Key:=Range("M1:M51816"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveSheet.AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
x = 2
Cells(x, 13).Select
Do While Selection.Value <> ""
Cells(x, 13).Select
Selection.Value = Selection.Value
x = x + 1
Loop
myrng = "Range(" & "A2" & ":R" & x - 2 & """)"
Debug.Print myrng
myrng.Select
' Range("A2:R19").Select
'Cells(x - 2, 3).EntireRow.Select
'Range(Selection, Selection.End(xlUp)).Select
I am getting error 91 object variable or with block variable not set. I don't get it. can someone please help?
Dim myrng As Range
With ActiveSheet
If .AutoFilterMode Then
.ShowAllData
End If
End With
ActiveSheet.AutoFilter.Sort.SortFields. _
Clear
ActiveSheet.AutoFilter.Sort.SortFields. _
Add Key:=Range("M1:M51816"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
With ActiveSheet.AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
x = 2
Cells(x, 13).Select
Do While Selection.Value <> ""
Cells(x, 13).Select
Selection.Value = Selection.Value
x = x + 1
Loop
myrng = "Range(" & "A2" & ":R" & x - 2 & """)"
Debug.Print myrng
myrng.Select
' Range("A2:R19").Select
'Cells(x - 2, 3).EntireRow.Select
'Range(Selection, Selection.End(xlUp)).Select
I am getting error 91 object variable or with block variable not set. I don't get it. can someone please help?