Sequence in VBA

randymone

New Member
Joined
Feb 17, 2023
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I can use a filter () function to get a specific value from a column in an excel table using filter(index(table, sequence(row(table)),{4}),criteria) in excel. where table = the table name and {4} is the table column for the result. I would like to convert this formula from excel to a vba process. The issue i am having is that curly bracket surrounding the 4 is identified as an invalid character in VBA. Any suggestions?
TIA.
Randy
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Just get rid of the {} as you do not need them for a single column.
 
Upvote 0
Just get rid of the {} as you do not need them for a single column.
Thanks for the response. It eliminated that issue, I am still having issues converting the filter() function from an excel formula to vba. Is this possible? I tried to use the evaluate function creating a string to test in an excel sheet (it worked), but using evaluate resulted in Error 2015. Here is the text sting

=FILTER(INDEX($R$3:$AC$110, SEQUENCE(ROWS($R$3:$AC$110)), 12), ($R$3:$R$110 = 62.1) * ($S$3:$S$110= "S")* ($AB$3:$AB$110 = ""))

and the vba code.

Evaluate("Filter(Index(" & tbldata & ", Sequence(Rows(" & tbldata & ")), 4), (" & cuid & " = " & CurrID & ") * (" & oid & "= " & qt & coid & qt & ")" & "* (" & DEL & " = """"))")

Any guidance would be appreciated. Let me know if you have any other questions.

Thanks!

Randy
 
Upvote 0
Without knowing what your data is like, or what all those variables are it's impossible to help.
 
Upvote 0
Thanks for the response. It eliminated that issue, I am still having issues converting the filter() function from an excel formula to vba. Is this possible? I tried to use the evaluate function creating a string to test in an excel sheet (it worked), but using evaluate resulted in Error 2015. Here is the text sting

=FILTER(INDEX($R$3:$AC$110, SEQUENCE(ROWS($R$3:$AC$110)), 12), ($R$3:$R$110 = 62.1) * ($S$3:$S$110= "S")* ($AB$3:$AB$110 = ""))

and the vba code.

Evaluate("Filter(Index(" & tbldata & ", Sequence(Rows(" & tbldata & ")), 4), (" & cuid & " = " & CurrID & ") * (" & oid & "= " & qt & coid & qt & ")" & "* (" & DEL & " = """"))")

Any guidance would be appreciated. Let me know if you have any other questions.

Thanks!

Randy
Hi,

The short answer is yes. You can do almost everything that worksheet formulas are capable of with VBA code. But, if you're just starting to use VBA code after a long time of using formulas, you need to change the way you think about manipulating the data. Often, in VBA, filtering data is done using Loops.
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,937
Members
449,094
Latest member
teemeren

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