The below code adds the at '@' symbol within the formula which causes the formula to not actually pull the correct data unless I delete the AT symbol. Why?
OUTPUT:
DESIRED:
OUTPUT:
=MIN(IF(@Appointments!B:B=A2,Appointments!A:A))
DESIRED:
=MIN(IF(Appointments!B:B=A2,Appointments!A:A))
VBA Code:
Sub Earliest()
Dim lngLastRow As Long
Dim wsOutput As Worksheet
Dim wsSource As Worksheet
Set wsOutput = Sheets("Main") 'Sheet name for the following VBA to fill in
Set wsSource = Sheets("Appointments") 'Sheet name containing completed data for MIN IF
lngLastRow = wsOutput.Range("A:C").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
With wsOutput
With .Range("C2:C" & lngLastRow)
.Formula = "=MIN(IF('" & CStr(wsSource.Name) & "'!B:B=A2,'" & CStr(wsSource.Name) & "'!A:A))"
End With
End With
End Sub