Class Modules: Class Object Can I Visually See It
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
ADVERTISEMENT
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
Feb 15, 2013
I have a problem with a dynamic userform that I need to create.
I need a userform in which the number of controls are determined by the some values in the worksheet. The users of the workbook must be able to add new controls to the form, so I do not know the number of controls in advance. I therefore can not create the userform through the design module but must create it through code instead.
I need a userform with a number of comboboxes and a commandbutton, which when clicked sends the content of the comboboxes to the first empty row in a worksheet.
My problem is that I can't assign any commands to the comboboxes (which are created at runtime), nor can I use the values of the comboboxes in any commands assigned to other controls in the userform (e.g. the commandbutton).
I have read as far that I probably need some form of class module to create the controls at runtime, but since I am relatively new at VBA, I'm having trouble getting the class module to work in connection with the userform.
View 2 Replies
View Related
Jul 8, 2009
I am working with a class module and some fields require specific inputs that another coder may not intuitively know. How can I create a list of acceptable conastants that will appear as a drop down when the user is coding with the custom object?
For example:
I am creating an Email Engine object that will handle all my emailing needs in code, because coding emails is such a pain. Then I can just create the blasted thing, import the class module where needed and never have to worry about it again. Some coworkers are interested in using the module for their projects when I am finished. I want to put an option for message flags in the object, but only certain colored flags are allowed. How can I get the VBE to show a little drop down with the acceptable flag constants when another user types
[Object Variable].MessageFlagColor = {drop down list of options}
I started with
Public Property Let MessageFlagColor(Value As Constants)
End Property
But that hasn't gotten me anywhere.
View 9 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
Aug 19, 2008
Split from Determine Order Of Event Procedures
I realise that there's no set order for different types of event, because, as you say, it basically depends on what the user does. But what I'd like to control is what order like events fire in.
So let's say that object_1 handles the aplApp_WorkbookNewSheet event (an application-wide event).
Let's say that object_2 is an object of the same type as object_1, and therefore also handles the aplApp_WorkbookNewSheet event.
The objects are entirely independent; they know nothing about each other. However, I would like to be able to control whether the aplApp_WorkbookNewSheet event is fired first in object_1 or first in object_2 when the user triggers this event by adding a new worksheet somewhere.
View 4 Replies
View Related
Jul 28, 2007
Error 1004 on the 5th "With Selection" Chunk, .LineStyle part.
What I did is recorded the formatting I wanted on a selected region, then changed the major references to the defined region in my code called rngATotals.
At first I got errors with the "Select" method of the "Range" class with my rngATotals line (the first one). But then I clarified public variables and now its in the formatting chunk that was recorded.
I've tried:
--Changing security/protection settings
--Clarifying my rngATotals references
--Making the sheet containing rngATotals visible (still in my code snippet)
--And not using rngATotals to define my range but more specific, clunky references like Range ("A3":"B7") or Range(Cells...,Cells...) or Range ("RAnge'sName")
What further could I clarify? And why does it have a problem with the 5th borders/linestyle reference and not the previous ones?
I hate to have to ask another question about this error because there are so many...
Is there anything beyond what I've tried that is a usual way to approach this problem?
Anyway heres the
Sub FormatTotalsTables()
'
' FormatTotalsTables Macro
' Macro recorded 7/22/2007 by AEB
SumSheet.Visible = True
rngATotals.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
View 9 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
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
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
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
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