Assistant with VBA code from formula

Newbie73

Board Regular
Joined
Feb 4, 2024
Messages
109
Office Version
  1. 365
Platform
  1. Windows
Hello, yet another formula that I would like to transform into VBA code but improve the calculation times of a big excel spreadsheet.

In this one on Sheet3 pulls the information from Sheet1 and Sheet3 combining it in just one array to then be worked with other formulas.

test12.xlsx

Let me know if I didn't explain well or if you need any more information, thanks!
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Excel Formula:
=LET(data,VSTACK(Sheet1:Sheet2!I2:L100000),FILTER(data,CHOOSECOLS(data,1)<>""))

Sorry should have added the formula itself here.
 
Upvote 0
How are you planning to use VBA? Functions written in VBA will generally not be faster than native Excel functions. That function would be better written as:

Excel Formula:
=LET(data,VSTACK(Sheet1!I2#,Sheet2!I2#),FILTER(data,CHOOSECOLS(data,1)<>""))
 
Upvote 0
Hello Rory and thanks for the reply! Ah I see, I thought code would usually be more efficient.

I've tried your revised formula but gave me an #REF error, also the range is from I2 to L (the end number varies from spreadsheet to spreadsheet, that's why I added the 100000)
 
Upvote 0
It works as posted in your example file, so I guess you did something wrong. ;)
 
Upvote 0
I did indeed! Sorry about it, could you explain how/what does the # in I2# actually does? Didn't know about that one
 
Upvote 0
I2# means the entire array returned by the formula in I2
 
Upvote 0
So that would be the whole array? Is there something similar for just a column (so until the columns no longer have results) and for a nomal range for example A1:B100000?

Because I do have this problem often, as data always change from sheet to sheet I usually put a safer number to make sure I cover cases where data is bigger than others
 
Upvote 0
If you just want a particular column you can wrap that in INDEX or CHOOSECOLS.

There isn't (yet, but it's coming!) an equivalent for normal ranges.
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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