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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Try changing
Excel Formula:
.Formula
to
Excel Formula:
.Formula2
 
Upvote 0
Happy it helped and welcome to the forum :)
 
Upvote 0

Forum statistics

Threads
1,214,958
Messages
6,122,475
Members
449,087
Latest member
RExcelSearch

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
Back
Top