Instantiate A Class
Jun 30, 2007
i have created linked list class data structure. But how am i going to instantiate the linked list class. Excel VBA keep complaint me "Object variable or with block variable not set". Can somebody point out my mistake...
Dim theList As New LinkedList
Dim i As Integer
i = 0
Debug.Print theList.count
For i = 0 To 5 Step 1
theList.InsertNode "address", "date", i '"
Set p = p.pNext
Loop
Set p = Nothing
End Sub
Property Let free(setFree As Boolean)
Set temp = Nothing
Set Head = Nothing
Set First = Nothing
Set holdPrev = Nothing
End Property
View 9 Replies
ADVERTISEMENT
Jul 23, 2009
i've reached a point where i would like to learn more about class modules but i have no resources. When i create a Class object can i visually see it? i want to know as i'm looking to use them within userforms if possible
View 4 Replies
View Related
Nov 25, 2008
I've created a class called CStock. It has 5 standard properties (with Get/Let methods) as explained in that article above. Nothing fancy here.
I also want to create a CPortfolio class that has 3 properties: pName, pNumberofPositions, and pHoldings. the first 2 are stardard, but the last one is different. I want it to somehow keep a collection of stocks.
View 10 Replies
View Related
May 24, 2006
I've created two modules, card and pack. Card has three variables (value, name, suit) and pack is made up of an array of 52 cards. Referencing it from a test module (NOT a class module) I expected to be able to use debug.print pack.card(32).suit to return the suit of the 32nd card. Instead I get an error message "Object or With variable not set". What am I doing wrong
Private p_strSuit As String
Private p_strName As String
Private p_iValue As Integer
Public Property Let Suit(strSuit As String)
p_strSuit = strSuit
End Property
Public Property Get Suit() As String
Suit = p_strSuit
End Property
Public Property Let Name(strName As String)
p_strName = strName
End Property......................................
View 7 Replies
View Related
Oct 14, 2008
I'm wondering about class modules and what they can be used for etc etc? i want to continue developing my VBA and feel that this area is the next step?
View 2 Replies
View Related
Jul 28, 2009
I have written a class that can be used as a replacement for Application.FileSearch in Excel 2007, that will take the same parameters etc. with no, or minimal code adjustments.
How do I now alter this so that it can be used as an AddIn by others?
I think that I have to remove all the sheets apart from 1 from the document, and save it as an .xla, but I am struggling with making this an addin, and then being able to use the addin from other code.
Does anyone have some instructions or a link to a website that could direct me? I have done a google search, but search for Excel, VBA, and classes (as well as AddIns), just gives lots of links to classes (as in teaching).
View 12 Replies
View Related
May 28, 2014
JSON import to Excel - Stack Overflow
I understand most of what this post is saying, but I don't understand how to put it together in an excel module or class module.
View 5 Replies
View Related
Feb 15, 2010
I would like to create a class module that it's the same as a connector shape (for example), but with additional custom properties defined by me. For example, I would like it to have a temperature property.
So, for example if I write in a Sub procedure:
Dim Test1 as EnhancedConnector
Set Test1 = New EnhancedConnector
A new connector appears in the activesheet, but this connector must have my custom defined properties available to VBA Code
View 9 Replies
View Related
Jul 23, 2007
I am creating a class of permutations. The problem is that there are many ways to describe what a permutation does. for example.
Dim aPerm As New clsPermutation
Dim bPerm As New clsPermutation
aPerm.DoesTranspose(2,3) : Rem aPerm.Action({a,b,c}) = {a,c,b}
MsgBox (aPerm Is aPerm.Inverse)
I want the message box to return True. But since aPerm and aPerm.Inverse are different instances of clsPermutaion, it returns False. (.Inverse is a read-only property that returns a clsPermutation.). What I would like to do is have a collection, myPermutations. When I specify the action that aPerm does, I would like
1) if nothing in myPermutations does the same thing as aPerm, then add aPerm to myPermutations.
2) if something (xPerm) does the same thing as aPerm, then
Set aPerm=xPerm
so that "xPerm Is aPerm" returns True.
The problem I have is that in the class module,.....................
View 8 Replies
View Related
Nov 25, 2013
I am trying to figure out a simple formula on determining class for students according to their achievement /grades. There are 9 classes altogether ( 7A, 7B, 7C, 7D, 7E, 7F, 7G, 7H and 7J). There are three columns for subject ( MATHS, ENGLISH, SCIENCE). So lets say the student get Grade A, A , A : The student will belong to Class 7A.
As attached.. TEST PSR.xls
View 2 Replies
View Related
Apr 16, 2014
I am creating my first class and it will be possible for the Class Initialize event to fire twice.
Is there any way to check if the Class is already "loaded" .
View 11 Replies
View Related
Jul 17, 2014
I have this textbox class which I want to show a userform when clicked and prevent manual input.
[Code] .....
I would expect that I could also set some object properties like color, width, height, locked etc. in the class module.
However I can't find how to (seen all corners of the internet). How do I set these properties?
View 10 Replies
View Related
Feb 4, 2014
I've got three workbooks that end users will be using for data entry. The VBA code for the three workbooks is identical.
I'm trying to encapsulate the code into an add-in so I only have one copy of the code that I have to debug/maintain.
Furthermore, I've also encapsulated the code in the add-in into a class. The class isn't really a "usual" object modelling some data; rather, it's a utility class processing Worksheet_Change and Worksheet_Activate events. Hopefully this isn't a really bad idea, rather than keeping the code in standard modules in the add-in.
The application is called "Midas". Here are some code excerpts:
Midas.xlam:
Standard Module:
[Code] ......
Class Module:
[Code] .....
And in the end user workbook:
[Code] .....
The Wbk_SheetChange event handler is triggering, but it's looking for the code in the end user workbook, instead of the class. Is there a way I can change
[Code] .....
to call the private routine "Cases_Changed" (where "Cases" is the sheetname) residing in the class instead of looking for it in the workbook?
View 4 Replies
View Related
Jan 8, 2010
Does anyone know of an Excel object class that you can put objects into with a key and the process it in key-sorted order? If not, is there a library that I can reference to get such a thing?
View 6 Replies
View Related
Apr 16, 2013
I am attempting to create an IF or IF(AND formula that I can use to display the letter grade I earned based off of a certain percentage criteria.
"A" D11>=93%
"A-" D11>= 90%, D11=87%, D11=83%, D11=80%, D11=77%, D11=73%, D11=70%, D11=67%, D11=63%, D11=60%, D11
View 7 Replies
View Related
Nov 10, 2013
Possible to create a class that contains a textbox and a label?
I need something like a checkbox except instead of showing a check mark, it shows how many time the checkbox is clicked.
What I can think of is a combination of a textbox and a label. When the label is clicked, the number in the textbox increases (or decreases, depending on a pre-set condition) by one.
View 3 Replies
View Related
Nov 29, 2007
I have a class
Private MemoryArray() As Variant
Private Sub Class_Initialize()
Redim MemoryArray(0) As Variant
End Sub
Public Sub ReplaceMemory(GivenArray() As Variant)
Redim MemoryArray(UBound(GivenArray)) As Variant
For Index = LBound(GivenArray) To UBound(GivenArray)
MemoryArray(Index) = GivenArray(Index)
Next Index
End Sub
that I am specificall passing an array to the replacememory sub. So in the program I have a global array doved criteria:
Dim Criteria() As String
Sub Product2()
'fill criteria with various entries
'do whatever in macro sub
Set MemoryCriteria = New Memory
MemoryCriteria.ReplaceMemory (Criteria)
and on the last line I get an error message:
Compile Error:
Type mismatch: array or user-defined type expected
View 9 Replies
View Related
Dec 16, 2013
I am creating a class list from a list of all students and classes. Names of students are in column A, their class name is in column B. In another sheet I would like to show a list of names from one particular class, say "Y8/En1".
Using a filter on the original list isn't an option as I will need it to pull/show other things eventually.
View 7 Replies
View Related
Dec 7, 2009
Unable to get the Match property of the worksheetfunction class? Here is my code
View 5 Replies
View Related
Feb 5, 2010
I'm getting an error when I try to set the XValues for a chart in my excel worksheet. The chart shows up fine and the new series adds fine though when I try to set the XValues the below error occurs
'Unable to set the Xvalues property of the Series Class' 1004. My Code is below. Can anyone see anything wrong with it? This could be a floor in my understanding of the chart object. I don't want to be selecting charts and working on an activechart because I'll have several in the one worksheet.
View 2 Replies
View Related
Nov 29, 2011
I receive the following error whenever I try to run a macro in Excel: "System Error &H80040111 (-2147221231). classFactory cannot supply requested class." This is immediately followed by "Out of memory"
I was eventually able to stop the error from occurring by removing all forms containing a listview control in my macro file.
I have tried repairing my Office installation, uninstalling and reinstalling Office, and reregistering MSCOMCT2.OCX but nothing seems to work.
View 9 Replies
View Related
Feb 10, 2013
Im wanting to get a function that can get the results I have in cols B and C from the data in col A .
I already have functions to get the 1400m and F1 as in cell A2 etc .
Sheet1 ABC1DataClassStakes2Mdn 3yo $6K 1400m F1Mdn 3yo$6K3OPN HCP C/WGT 1000 SOPN HCP C/WGT 4HCP $58K 1110m GHCP$58K5GRAZIA STYLE $177K 1100m GGRAZIA STYLE$177K60 - 91 $80K 1200m G0 - 91$80K7Rating 70 SW+P $10K 1400m G3Rating 70 SW+P$10K8MDN 2YO C/WGT 450 DMDN 2YO C/WGT 9OPN HCP $100K 1400m H10OPN HCP$100K10Mdn & JMP HWT $6K 2100m G2Mdn & JMP HWT$6K
View 2 Replies
View Related
Nov 15, 2013
Code:
Private garage_ As Collection
Public Property Get garage() As Collection: Set garage = garage_: End Property
Public Property Set garage(ByVal value As Collection): Set garage_ = value: End Property
[Code]...
I have the above piece of code within a "Person class" in order to add a vehicle to a person's garage. I was wondering if there is a better way to structure and/or execute this? (Perhaps not using a collection? or my adding to the collection directly?)
View 5 Replies
View Related
Aug 29, 2002
i just figured out that when you change sheets too often in VBA and get an "Activate Method Of Range Class Failed" or a "Select Method Of Range Class Failed" etc, simply retype the sheets command before it
for example :
Sheets("Work1").Select
Range("A1:D50").Select
OR
Sheets(Work1").Range("A1:D50").Select
this code in VBA, if used too often or the mentioned sheet is not the currently selected sheet in a Sub, will cause errors, and to correct this, simply type
Sheets("Work1").Select
Sheets("Work1").Range("A1:D50").Select
this makes sure that the sheet is selected before running any other range/sheet type commands.
View 2 Replies
View Related
Jul 4, 2008
I want to do is to count the number of people under each class, eg. 2300 - primary, 3 ppl, but i gt many many classes in my spreadsheet, do u all have solution for me using VBA
SAMPLE DATA:
2300 - primary
amy
ben
alex
1234 - secondary
Linda
tom
Jerry
Tricia
Mabel
5603 - advanced
Linda
tom
Jerry
Kevin
Calvin
View 9 Replies
View Related
Oct 16, 2008
work around the sum error?
Runtime Error '1004'
unable to locate the sum property of the worksheetfunction class
Public Function CalcSheet()
Dim NoSales(0 To 11) As Range
Dim DriveOffs(0 To 11) As Range
Dim Voids(0 To 11) As Range
Dim Shortages(0 To 11) As Range
Dim tNoSales As Integer
Dim tDriveOffs As Currency
Dim tVoids As Currency
Dim tShortages As Currency
Dim X As Integer
Dim NSc As Integer
Dim DOc As Integer
Dim VOc As Integer
Dim SHc As Integer
Dim aNoSales As Integer
Dim aDriveOffs As Currency
Dim aVoids As Currency
Dim aShortages As Currency
View 9 Replies
View Related
Aug 10, 2009
I wrote the following macro to copy some values from a master workbook to a new one. It works superb on my small test sheet but once I try to implement this on my big mastersheet I only get the "Pastespecial of range class failed" on the second pastespecial operation. Why does it work on my small test sheet and not my big master sheet?
Sub ReportGenerator()
Dim NewWorkbookFileName As String
NewWorkbookFileName = ActiveSheet.Name & " report" & " as of " & ThisWorkbook.BuiltinDocumentProperties("Last Save Time")
'Debug.Print NewWorkbookFileName
Cells.Select
Selection.SpecialCells(xlCellTypeVisible).Select
Application.CutCopyMode = False
Selection.Copy
Workbooks.Add xlWBATWorksheet
Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("a1").Select
Application.GetSaveAsFilename (NewWorkbookFileName)
End Sub
View 9 Replies
View Related
Nov 23, 2008
What exactly is a Class Module? I've tried doing some searching on Google and haven't really found a straight answer as to what a class module is and what it is used for. How does it differ from a Normal Module?
View 2 Replies
View Related
Apr 29, 2006
I am trying to use the application .ontime procedure to run a class method, but having a little trouble with what to use as my procedure name. Do I have to include the name of the class, or the name of the instantiation of the class, or what? Here is kind of what I have in the "myClass" class module:
Option Explicit
Private WithEvents m_cmdButton As MSForms.CommandButton
Private m_iTimer As Double
Private Sub m_cmdButton_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
' Set the time with the long delay
m_iTimer = Now + TimeSerial(0, 0, I_TIMER_DELAY_LONG)
' Start the timer
Call Application.OnTime(earliesttime:=m_iTimer, procedure:="ClickAgain", schedule:=True)
End Sub
Private Sub ClickAgain()
Call MsgBox("ClickAgain successfully called.", , "Boo yeah!")
End Sub
I have checked and the MouseDown event is being registered: it will work if I use a procedure in a standard module rather than the class method"ClickAgain". (I am only including the code relevant to the "ontime" procedure. My actual class has other methods to deal with setting the control source for the command button & everything.)
View 6 Replies
View Related
Apr 17, 2007
I have 4 checkboxes
Actual 2006
Budget 2006
Actual 2007
Budget 2007
Say when the box Actual 2006 is clicked the code is...
If Columns("U:IV").EntireColumn.Hidden = False Then
Columns("U:IV").EntireColumn.Hidden = True
ElseIf Columns("U:IV").EntireColumn.Hidden = True Then
Columns("U:IV").EntireColumn.Hidden = False
End If
But when I click it, I get this error message. "Unable to Set the Hidden Property of the Range Class"
View 5 Replies
View Related