VBA is adding "@" to MIN/IF formula

KyleW

New Member
Joined
Sep 18, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
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: =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
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
14,048
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
Try changing
Excel Formula:
.Formula
to
Excel Formula:
.Formula2
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
14,048
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
Happy it helped and welcome to the forum :)
 

Watch MrExcel Video

Forum statistics

Threads
1,129,513
Messages
5,636,773
Members
416,939
Latest member
Rajakumaran

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top