Forum Discussion

GeorgieAnne's avatar
GeorgieAnne
Iron Contributor
Mar 22, 2025
Solved

Why is MS-Excel adding an "@" to my formula and breaking it???

Hello Excellers,

This is so annoying and it is breaking my formula. I hope someone has a good solution:

 

In VBA I have these two lines:

Range("N1").Value = "3/24/2025"

Range("N2").Formula = "=INDEX(" & Range("E3:E" & lLastRow).Address & ",MATCH(MIN(ABS(" & Range("E3:E" & lLastRow).Address(ReferenceStyle:=xlA1, RowAbsolute:=False, ColumnAbsolute:=False) & "-$N$1)),ABS(" & Range("E3:E" & lLastRow).Address & "-$N$1), 0))"

 

Now in N2 I get this formula: 

=INDEX($E$3:$E$1029,MATCH(MIN(ABS(@E3:E1029-$N$1)),ABS(@$E$3:$E$1029-$N$1), 0))

And I get an error in cell N2 and I will need to remove the @s and it works ad needed.

This works and this is what I need and this is what the VBA code is supposed to put in cell N2.

=INDEX($E$3:$E$1029,MATCH(MIN(ABS(E3:E1029-$N$1)),ABS($E$3:$E$1029-$N$1), 0))

This formula is going to give me the closest date after what I put in N1, and it works very well,

I just need to tell Excel not to add the unwanted @ signs!

Is that because E3:E $ lLastRow is considered an array?

 

Thanks for any help!

GiGi

2 Replies

Resources