VBA Formula query

reissmiltiadous

New Member
Joined
Jan 21, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi,

ThisWorkbook.Worksheets("(1)").Range("B6").Formula = "=IFERROR(UNIQUE(FILTER(VSTACK('Prior TB Backend'!A2:A" & RowNumCombinePrior & ",'Opening TB Backend'!A2:A" & RowNumCombineOpening & ",'Closing TB Backend'!A2:A" & RowNumCombineClosing & "),VSTACK('Prior TB Backend'!A2:A" & RowNumCombinePrior & ",'Opening TB Backend'!A2:A" & RowNumCombineOpening & ",'Closing TB Backend'!A2:A" & RowNumCombineClosing & ")<>" & Chr(34) & Chr(34) & "))," & Chr(34) & Chr(34) & ")"

Sorry it's a bit long winded but I'm trying to get the script above to paste in an Excel formula for me but using VBA variables. The whole thing pretty much works but for some reason it just adds a "@" after the "=" and I don't have a clue why. I have attached a screenshot of this so you can see, this means the formula doesn't work. If I just take out the "@" myself in Excel then the whole formula works perfectly however I've tried everything I can think of and nothing seems to get rid of the "@" without breaking the script.

To give context, the formula above is used to pull all of the unique entity names from a list that is generated by my script. RowNumCombinePrior, RowNumCombineOpening, RowNumCombineClosing are just variables to record the number of lines of data in each sheet.

Any help would be greatly appreciated.

Excel.png
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Re: This line
ThisWorkbook.Worksheets("(1)").Range("B6").Formula
1) Do you have a sheet called (1) ?
I thought you might have been refering to the 1st sheet in the workbook in which case it should be:
ThisWorkbook.Worksheets(1)

2) You are using an array formula, try changing ".Formula" to ".Formula2"
Rich (BB code):
ThisWorkbook.Worksheets("(1)").Range("B6").Formula2
 
Upvote 0
Re: This line
ThisWorkbook.Worksheets("(1)").Range("B6").Formula
1) Do you have a sheet called (1) ?
I thought you might have been refering to the 1st sheet in the workbook in which case it should be:
ThisWorkbook.Worksheets(1)

2) You are using an array formula, try changing ".Formula" to ".Formula2"
Rich (BB code):
ThisWorkbook.Worksheets("(1)").Range("B6").Formula2

That worked, just needed to change it to formula2.

Thank you so much!
 
Upvote 0

Forum statistics

Threads
1,216,030
Messages
6,128,405
Members
449,448
Latest member
Andrew Slatter

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