VBA Adding @ to variant Formulas

seniorjerry

New Member
Joined
Jan 20, 2023
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hey I'm writing a VBA function to generate a couple reports in a consistent printable format. Everything is working fine thus far except that variable functions I am inputting into a cell are adding an @ symbol and breaking the function making it have to be manually fixed. Is their a way to make it stop including these @ symbols?

VBA Code:
    For L2 = 2 To 12
        CellChar = Switch(L2 = 2, "B", L2 = 3, "C", L2 = 4, "D", L2 = 5, "E", L2 = 6, "F", L2 = 7, "G", L2 = 8, "H", L2 = 9, "I", L2 = 10, "J", L2 = 11, "K", L2 = 12, "L")
        CellChar2 = Switch(L2 = 2, "C", L2 = 3, "D", L2 = 4, "E", L2 = 5, "F", L2 = 6, "G", L2 = 7, "H", L2 = 8, "I", L2 = 9, "J", L2 = 10, "K", L2 = 11, "L", L2 = 12, "M")
        Sheets("VLF").Cells(XLoc + 3, L2 + 1) = "=COUNTIFS(Rent_Roll[UnitType],$" & CellChar & XLoc + 3 & "#,Rent_Roll[LeaseTo],"" >= ""&" & CellChar2 & "$" & XLoc + 1 & ",Rent_Roll[LeaseTo],"" <= ""&" & CellChar2 & "$" & XLoc + 2 & ")"
    Next L2

I cut out the part of the code that matters and put it here. This keeps resulting in
Excel Formula:
=@SORT(UNIQUE(Rent_Roll[UnitType]))
instead of
Excel Formula:
=SORT(UNIQUE(Rent_Roll[UnitType]))
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Just realized I copied the wrong code snippet meant to paste this formula

VBA Code:
Sheets("VLF").Cells(XLoc + 3, 1).Formula = "=SORT(UNIQUE(Rent_Roll[UnitType]))"
 
Upvote 0
Alright New problem found now that original code snippet is out putting an @ before the first cell location instead of before the countifs and Im not sure how to fix this one.
 
Upvote 0

Forum statistics

Threads
1,223,879
Messages
6,175,148
Members
452,615
Latest member
bogeys2birdies

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