I fixed the brackets. Now I get a Run-time error: Method 'Range' of object '_Global' failed.
Code:
Sub GetInProgress()
Dim wb As Workbook, src As Workbook
Dim sht As Worksheet, cel As Range
Dim LR As Long
Set sht = ThisWorkbook.ActiveSheet
'remove existing data
With sht.UsedRange.Offset(1)
.Borders.LineStyle = xlNone
.ClearContents
End With
'see if source is open
For Each wb In Application.Workbooks
If wb.Name = "SearchResultsInProgress " & Format(Date, "m.d.yy") & ".xls" Then
Set src = wb
Exit For
End If
Next wb
'if yes copy data
If Not src Is Nothing Then
src.Sheets(1).UsedRange.Offset(1).Copy
'if no display message and quit
Else
MsgBox "Workbook " & Chr(34) & "SearchResultsInProgress " & _
Format(Date, "m.d.yy") & ".xls" & Chr(34) & " is not open."
Exit Sub
End If
'paste the copied data
With sht
.Cells(2, 1).PasteSpecial (xlPasteValues)
'name sheet
' .Name = Left(src.Name, Len(src.Name) - 4)
' E from F if blank
For Each cel In Intersect(.Columns("E"), .UsedRange)
If cel.Value = "" Then cel.Value = cel.Offset(, 1).Value
Next cel
'position the cursor for sorting
.Cells(2, 5).Select
'determine last row
LR = .Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
With .Sort
.SortFields.Clear
.SortFields.Add Key:=Range("E2"), SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortTextAsNumbers
.SetRange Range("A2:N" & LR)
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("K2:N").Select
With Selection
Selection.NumberFormat = "General"
.Value = .Value
End With