Purpose And Definition Of Class Module

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


ADVERTISEMENT

Class Module Is Collection Of Other Class

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

Class Module

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

Sharing Class Module Among Multiple Userforms?

Apr 22, 2014

I have two user forms, each with a checkbox for Jan-Dec. Also, I have a checkbox "All" to check/uncheck the Jan-Dec boxes. I also created a class module so that if any of the Jan-Dec boxes get unchecked, while the "All" box is still checked, it will uncheck the All box. Basically I just don't want the All checkbox to be able to be checked while any single month is unchecked. The only/easiest way I found to do this was with a class module, so I would not need to create individual Checkbox_Jan_Click() events for each month.

Now my issue is, I have 2 userforms like this. I'd like them to share the same class module, but in the class module I need to refer to UserForm1.CheckBox_All. So I need to dynamically refer to whichever userform was active, but as far as I can tell, this is not possible.

View 4 Replies View Related

Creating A Class Module For Dbl Clicking Label

Jul 27, 2009

i would like to do is create a class module so that when the user double clicks on a label a msgbox will open saying the name of the double clicked label. If someone can get me to this point i can modify the code to suit my needs.

Some other things really quick though. I have 80 labels, but i only need this to work for labels 1 through 40 and the labels are on a multipage control within the userform.

View 5 Replies View Related

Call Public Function From Class Module

May 25, 2006

I have written a public function inside a class module. Is there anyway I could call the public function in Excel? What is the exact syntax to do it?

View 5 Replies View Related

Class Module Change Event For Controls

Nov 20, 2006

I have a class module (MyCtrlEvents) with a sub (TxtGroup_Change) which I want to handle on a change event for some specific textboxes.

When the form is opening I don't get the correct sum for the textbox "TBSum601". It should be 200 but I get 14464

When I then also change a number in the form for any control like "TB7%", the change trigger event doesn't seem to occur....

View 9 Replies View Related

Using Class Module For Handling Events Of Dynamically Created Controls

Mar 4, 2009

I have a userform with a single blank multipage. At runtime additional pages are added, the number of pages depends on input from another userform. Six frames, containing labels, textboxes and comboboxes are then added to each page.

I need to be able to use the textbox and combobox change events of these dynamically created controls to perform lookups and calculations. Although I can name the controls at the time they are created, it is not feasible to write code specifically for each control (I can have over 1,600 text boxes distributed over 9 pages, for example).

Having searched for some time on how to achieve this I believe using a class module is the way to go. However, how to use a class module is just not sinking in I'm afraid.

HTML Private WithEvents mpTextBox As MSForms.TextBox
Private WithEvents mpComboBox As MSForms.ComboBox

Private Sub Class_Initialize()
Set mpTextBox = MSForms.TextBox
Set mpComboBox = MSForms.ComboBox
End Sub

Private Sub mpComboBox_Change()
MsgBox "ComboBox value has been changed."
End Sub...........................................

View 2 Replies View Related

Purpose Of Investment Calculators

Oct 24, 2007

I am part of an investment sales team and was wondering if the use of specific excel based investment calculators will assist me in my task of advising clients of the best options. Also; if these tools do help, I wanted to create a calculator that displayed the interest schedule depending on the term that its invested for. I have searched and found various threads on this topic; though not too sure how

View 2 Replies View Related

Keeping Track Of Which Macro Is In Which Module Since You Can't Rename The Module?

Mar 27, 2009

After all the awesome macros I've obtained with the help of all of you, I now have over 30 macros, each in its own module. I have tried without success to re-name the modules with no luck. How is everyone organizing these?

View 2 Replies View Related

Kth Value Definition

May 10, 2007

I do not have a strong math background. I am quite sure the term "kth" I see in different examples is a reference to a variable.

View 9 Replies View Related

Copy Codes Of Module 1 And Transfer To Module 2?

Jan 24, 2013

Let's say i have 2 Modules on my VBA forms, is it possible to Copy all the Codes in Module 1 and Paste it to Module 2 by using a Command Button?

View 1 Replies View Related

Making Msgbox In One Module With (Yes) Linking To Different Module

Jan 19, 2012

i got a question how i can make a msgbox in one module with 'Yes' linking to a different module.

such as: this is located in module2

Code:
If MsgBox("Do you want to activate module1?" & vbCr & _
"" _
, vbYesNo, "Choose") = vbNo Then Exit Sub

i want that vbYesNo different

No as in Exit Sub

yes as in activate Module1

View 5 Replies View Related

Cell Definition With 3 Assumptions.

Dec 15, 2008

I am finding a formula for the following problem (vlaue in A3 is variable):

B3 cell definition
1/ if A3<=A2, then choose value in B2
2/ if A3>A2 and A3>A4, then "(B4-B2)/(A4-A2)*(B3-B2)+B2"
3/ if A3>A4, then choose value B4

View 4 Replies View Related

Dynamic Range Definition

Jul 27, 2009

I can select a range within my worksheet but need a way in which I can get the range address information so that I can use

"activeWorkbook.names.add name:="EmployeeData", refersToR1C1:= "

View 9 Replies View Related

VBA To Remove Query Definition

Jan 29, 2011

My WB imports external data on file open

I want to extend my VBA code to uncheck "Save query definition" after the updated workbook is saved.

View 4 Replies View Related

Translating A Vba Range Definition

Sep 25, 2006

The following VBA code, when run, comes out in Excel erroneously as =INDEX(EL!'AI13':'AI32',MATCH(Myinput,EL!'AI13':'AI32',0)+1,1

instead of

=INDEX(EL!AI13:AI32,MATCH(Myinput,EL!AI13:AI32,0)+1,1

Worksheets("Inputs"). Range("C1").FormulaR1C1 = "=INDEX(EL!AI13:AI32,MATCH(Myinput,EL!AI13:AI32,0)+1,1)"

View 2 Replies View Related

Change Definition Of A Range Name

Nov 11, 2006

I have five macros that look like this

Sub Region1()
ActiveWorkbook. Names.Add Name:="Region_Name", RefersToR1C1:= _
"=Scroll.xls!Name_1"
ActiveWorkbook.Names.Add Name:="Region_Values", RefersToR1C1:= _
"=Scroll.xls!Region_1"
End Sub

Sub Region2()
ActiveWorkbook.Names.Add Name:="Region_Name", RefersToR1C1:= _
"=Scroll.xls!Name_2"
ActiveWorkbook.Names.Add Name:="Region_Values", RefersToR1C1:= _
"=Scroll.xls!Region_2"
End Sub...............

In the chart Region_Name is the name of the series Region_Values is the values of the series. I have a button for each routine. I want to use only one button instead. How?

View 3 Replies View Related

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 View Related

Sort By Definition? And Auto-fill Lists?

Oct 7, 2008

I update a daily incident report that is sorted by priority of the request as well as the date/time. In the past, I've recorded and run macro's to add a number to a priority so that it can sort numerically. Lately I've been tasked with building similar functionality into more reports. I am wondering whether I can tell Excel what order to sort items into (ie "Sort by HIGH, then MEDIUM-HIGH, then MEDIUM, then LOW)?

With regards to auto-fill lists (for want of the proper name), I report on multiple IT systems that fall into six "system" categories. Is there a way I can set up the "System" column to automatically update the correct data once the IT service is entered, rather than manually look up systems category then click the relevant system in the drop down box?

View 4 Replies View Related

Disable Save Query Definition Option Vba

Jan 25, 2007

I want to be able to disable the save query definition option for a worksheet using VBA. Right now I have to right click a cell and then go to Data Range Properties and then uncheck the save query definition box. If there is a way to automate this that would be great.

View 3 Replies View Related

Calling Module In Module With Variables

Oct 25, 2011

What i have at the moment is a module that contains code where i call a different module that i use as a procedure.

Module1

Code:
If Sheet1.Range("C4").Value < Sheet1.Range("A2").Value Then
If Sheet1.Range("K4") = "" Then
MsgBox "Please check 06:00 tasks not done yet!"
Cell = "Range(" & Chr(34) & "F4" & Chr(34) & ")"
If Sheet1.Range("C4") + 0.042 < Sheet1.Range("A2") Then
Run "EmailProSheet"
End If
End If
End If

EmailProSheet is what i call but now i want to use the variable "Cell" in the procedure as well?

Module3

Code:
MsgBox Cell
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next

[Code]........

As it is now everything is working fine but does not return a value in "Cell" if the procedure is called. Is there another way?

View 5 Replies View Related

Pick From List Or Combo Box And Return Definition In Cell To The Right..

Jan 18, 2009

In my attachment, I have a worksheet where I need to pick a rating from a combo box or list (Expert, Leading, Applying, Learning, Under Performing). I will be picking this rating 10 different times on this worksheet and the selections will not be the same in all cases so the definition I need won't always be the same.

I would like to return the definition (definitions are detailed on another worksheet, Data Elements) to the cell to the right.

I've tried IF statements but when I make one selection from the combo box, all the combo boxes select the same thing. I've also tried vlookup but can't figure it out and can't find an explanation in layman's terms.

View 2 Replies View Related

Class With Property As Collection Of Another Class

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

Run-time Error '50289' :: Project Protection / Module Protection / Module Visibility

Aug 18, 2004

I recieve an error :

Run-time error '50289':
Can't perform operation since the project is protected.

When i try and run my code.

The code does add parts to modules and workbook events, but I need the code to be protected.

View 9 Replies View Related

Count All Unique Values (text) + Definition Of UNIQUE :D

Aug 24, 2009

If I have multiple entries with different but repeatable text values in one column - how do I count all unique ones ? Is there a function or does it have to be a pivot table of sth ?

View 14 Replies View Related

Run Module Through Userform

Dec 21, 2012

I have created an Excel Add-in to create the Text file. I want to create the text file through select sheet from userform.

View 9 Replies View Related

How Long / Big Should A Module Be

Jun 17, 2014

In my Personal Macro book, I have 2 modules, one for Functions and one for "macros".

Is there a point where it's more efficient to make a new module (or is the opposite true and it's more efficient if they are all in one)?

Does having a plethora of sub routines in a module slow down excel even though the routines are short? or would having them in different modules slow it down more?

View 4 Replies View Related

Saving A Module

Aug 24, 2008

I have been making and so i thought saving a module however every time i close the spreadsheet that module is associated with it deletes. is there any way to prevent this from happening.

Also when trying to edit on PERSONAL.XLSB!Module1 i get a particular error stating
"cannot edit a macro on a hidden workbook. Unhide the workbook using the Unhide command."

View 12 Replies View Related

Delete A Module?

May 25, 2009

I inserted a second module into a project. Now I want to delete it. Only i can't figure out how to do this. I highlite it and right click or click edit from the toolbar but i'm provided no options. I can't drag it to the trash either.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved