I have a Macro I created to unprotect a sheet, deselect blanks, sort a column, re apply the blanks, and then re protect a sheet. The code works excellently on my computer, but when I try opening it on other computers, I get
an error code 438.
NOTE: I need to select blanks because I'm trying to sort columns with a formula. The columns will not sort correctly because the formula displays blanks in areas where information is missing.
All computers have the same operating system, the same version of excel, and the file is saved on a shared drive, so nothing should be changing. I've made sure that I enabled macros on each computer, but it still does not work.
Below is the code. Does anyone see any glaringly obvious issues I'm missing? I'm new to VBA and Macros but I've done a fair amount of reading and researching and cannot seem to figure this out.
Below is the updated code:
Sub Short2Long()
'
' Short2Long Macro
'
'
Worksheets("Reunification").Unprotect
Worksheets("Reunification").ListObjects("Reunification_Main").Range.AutoFilter Field:=1, _
Criteria1:="<>"
ThisWorkbook.Worksheets("Reunification").ListObjects("Reunification_Main"). _
Sort.SortFields.Clear
ThisWorkbook.Worksheets("Reunification").ListObjects("Reunification_Main"). _
Sort.SortFields.Add2 Key:=Range("Reunification_Main[[#All],[Days in Care]]") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortTextAsNumbers
With ThisWorkbook.Worksheets("Reunification").ListObjects( _
"Reunification_Main").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Worksheets("Reunification").ListObjects("Reunification_Main").Range.AutoFilter Field:=1
Worksheets("Reunification").Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
False, AllowFormattingColumns:=True, AllowFormattingRows:=True, _
AllowSorting:=True, AllowFiltering:=True