VBA Issue With cls module.

Radoslaw Poprawski

Active Member
Joined
Jun 19, 2021
Messages
405
Office Version
  1. 365
Platform
  1. Windows
Hello
I am working on a code and I decided to use this video for help:

I am using excel 365 newest eddition,
Sadly I am getting error here:
VBA Code:
VERSION 2.0 CLASS
BEGIN
  MultiUse = -1  'True
End
Attribute VB_Name = "clsArray2D"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit
the code is red and when I try running this:

VBA Code:
Option Explicit
Sub GetData()

Dim TrialBalanceReckonciliationData As New clsArray2D
Dim NotesCombined As New clsArray2D
Dim BookKeepingCombined As New clsArray2D
Dim TrialBalanceCombined As New clsArray2D
Dim CompanyCode As New clsArray2D
Dim FilteredData As New clsArray2D

TrialBalanceReckonciliationData = ShTrialBalanceReckonciliation.ListObjects("TrialBalanceGroupedByReckon").Range
NotesCombined = ShNotesCombined.ListObjects("NonPandLItemNotesCombined").Range
BookKeepingCombined = ShBookKeepingCombined.ListObjects("BookKeepingCombined").Range
TrialBalanceCombined = ShTrialBalanceCombined.ListObjects("TrialBalanceCombined").Range

CompanyCode = 340

FilteredData.data = TrialBalanceReckonciliationData.Filter(CompanyCode, 1)


Stop
End Sub

I am getting this error:
1738825269227.png


1738825294809.png


Can I ask for help in fixing this?
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
You should never see that code. I would suspect you have copied and pasted into the VB editor when you should have pasted into a text file, saved it with a .cls extension and then imported that into the VB editor.
 
Upvote 0
when I am importing it as you are saying I am getting this error:
1738833319661.png

So I opened in txt editor copied and pasted it manually.

in this case - how can I Import it differently?
 
Upvote 0
Ok, I have managed to make this class work. Thank you.

But now I am struggling with my next step,
Option Explicit
VBA Code:
Sub GetData()

Dim TrialBalanceReckonciliationData As New clsArray2D
Dim NotesCombinedData As New clsArray2D
Dim BookKeepingCombinedData As New clsArray2D
Dim TrialBalanceCombinedData As New clsArray2D
Dim CompanyCode As Long
Dim FilteredDataTBR As New clsArray2D
Dim FilteredDataNPLINC As New clsArray2D
Dim FilteredDataBKC As New clsArray2D
Dim FilteredDataTBC As New clsArray2D
Dim FilterFunction As New ClsCompareWHeaders

TrialBalanceReckonciliationData.dataFromRange ShTrialBalanceReckonciliation.Range("A16").CurrentRegion
NotesCombinedData.dataFromRange ShNotesCombined.Range("A1").CurrentRegion
BookKeepingCombinedData.dataFromRange ShBookKeepingCombined.Range("A1").CurrentRegion
TrialBalanceCombinedData.dataFromRange ShTrialBalanceCombined.Range("A1").CurrentRegion

CompanyCode = 123
Stop

FilteredDataTBR.data = TrialBalanceReckonciliationData.filterByFunction(FilterFunction) '<- here I have the problem

Stop
End Sub
Now in the line between Stop and Stop at the end I need to pass company code.
How Can I modify it?
 
Upvote 0

Forum statistics

Threads
1,226,453
Messages
6,191,134
Members
453,642
Latest member
jefals

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