Class Modules: Provide Users With In-Code List Of Constants

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


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

Class Modules?

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

Dynamically Create Userform Through Class Modules?

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

Use Combobox - Provide Range / List In The Properties?

Dec 26, 2012

I like to use the combo box (Active X control). where I need to provide the range/List in the properties. While inputing the value in properties it is disappeared.

View 1 Replies View Related

Protect VBA Modules & Code

May 18, 2009

I would like to protect the VBA modules I have written in a spreadsheet. Is there any way of password protecting these (as there is with Excel workbooks/worksheets) -such that users can not see the VBA code unless they enter a password?

View 4 Replies View Related

Validations: Provide The Ability To Format The Fonts In The List

Nov 29, 2005

In MS Excel, I find that when the zoom is dropped to 50% the fonts in the
list become unreadable. Is there anyway that the fonts in the list have the
ability to have their own formats?

View 10 Replies View Related


Jun 8, 2007

A recent message prompted me to complete a project to show all modules and subroutines in a workbook.

As use of VBA to manipulate the VB Editor is a recurring issue I thought it a good idea to share this.

Option Base 1
Dim WBname As String
Dim ws As Worksheet
Dim TitleStr As Variant
Dim VBProject As Object
Dim ToRow As Long
Dim ToCol As Integer
Dim ComponentType
Dim MyComponent As Object
Dim ComponentName As String
Dim TypeArray As Variant
Dim StdCol As Integer
Dim LastLine As Long
Dim CurrentLineNumber As Long
Dim CurrentLineText As String
WBname = ActiveWorkbook.FullName
On Error Resume Next
Set ws = ActiveWorkbook.Worksheets("WB Contents")
If Err.Number 0 Then ' sheet not exist....................

View 2 Replies View Related

Provide Filter With A List Of Criteria But When It Doesn't Match All Of The Criteria?

Apr 1, 2014

Is there a way to provide filter with a list of criteria but when it doesnt match all of the criteria it still uses the filter on the criteria that it does match?

E.g i have this code

ActiveSheet.Range("$A$7:$N$31997").AutoFilter Field:=1, Criteria1:=Array( _
"A", "B", "D", "E", "H", "I", "R"), Operator:=xlFilterValues

However sometimes for example B will be missing, or H or B H I will be missing etc... is there a way to provide all of the criteria and it will not error if the criteria is not all there?

View 1 Replies View Related

VBA Code Won't Stop Users Using Spreadsheet After Certain Date?

Jul 28, 2014

The code that I'm using is supposedly not allow spreadsheet to be opened after a certain date, or does not allow a user to press any of the command buttons and comes up with a message saying the spreadsheet is closed for new entries.But is not working for me.

I placed the Code in the ThisWorkbook module.


View 8 Replies View Related

Check Users Permissions Before Executing Code

Apr 13, 2011

I have a file I created which works fine for me, on my machine at least but there are two issues I'm trying to sort out.

The first issue is I need to share the file with others who may not have the same access rights. I have something loading in the Workbook_Open event which I want to bypass for users who do not have access to a specific folder. So I was trying to check their access using Dir(path) = "" at the top level folder to see if any files are present (which there are). My assumption was that if it finds files it's safe to assume they have permission and it's ok to continue, otherwise they don't in which case I want abort the rest of the code. This seems to work fine for me but I tried testing with someone I know does not have access and it gave her a compile error.

Part of the code in macro utilizes FileSystemObject which seems to be the line where the code bombs on my coworkers machine. The FSO seems related to appears related to the Microsoft Scripting Runtime reference, but it's not enabled on my machine or any of the others. I vaguely remember having to do something on my machine awhile back for the life of me don't remember what it was.

The second issue is an MS Forms error: "Could not load some objects because they are not available on this machine." appears when opening the file on three of the machines I tested but it does not appear on my machine. I've tried looking at the references and could not find any differences between the machines. I pored through various postings online and it appears it might be worth re-registering the DLL/OCX files but we need admin rights to do that so I will need to open a request with our support team.

View 2 Replies View Related

Creating VBA Code That Uses Input From Users To Create A Calendar

Sep 18, 2012

Modify Macro3 and use the InputBox function twice so that Macro3 would ask the user for a particular month and a particular year; and then Macro3 uses these user’s inputs to create the calendar template for that month of the year. For example, if the user enters February for the month and 2012 for the year, Macro3 would create a new


Sheets("Template").Copy After:=Sheets(1)
Sheets("Template (2)").Select
Sheets("Template (2)").Name = "January"


View 1 Replies View Related

Create Class List From All Lists

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

Creating E-mail Addresses From A List Of Users

Oct 13, 2007

I have a list of names in one excel column:

user5 etc etc

And I wish to add to each user to create e-mail addresses. How would I go about this?

View 9 Replies View Related

Lock Data Validation List For Certain Users

Feb 26, 2009

i have a query spreadsheet where all business queries are logged. Next to each query you need to select a resolving reason from a drop down list, however i would like some of these to be locked so only certain people could use them.

Lets for ease of use the resolving reasons are the following -

Not paid
Allocated Correctly

And say the drop down list is in column P

I would like everyone to use the top 2 but only certain members of the team to be able to use the last one.

I was thinking protect the cells in some way and a worksheet change event of some kind so protect / unprotect depending on the resolving reason.

View 9 Replies View Related

Clear Method Range Class Failed - Combobox Code

Apr 23, 2014

I have two separate workbooks, the first is called Job test and is to be used as a template for quoting jobs, the second is called Fixtures and is a database of fixtures that are organized in table. I keep them separate as multiple jobs will use the Fixtures DB workbook and I want to be able to update it and add new fixtures in one area. In order to facilitate this I have a macro that opens the Fixtures DB workbook anytime that the Job test workbook is opened. In the Job test workbook I have multiple dropdowns that I hope to make dependent or cascading by means of filtering the Fixtures DB workbook. The issue I have run into is with the following code.

Private Sub CLightType_Change()'Filters LampType
Workbooks("Fixtures.xlsm").Sheets("Fixtures").Cells.AdvancedFilter Action:=xlFilterCopy, CriteriaRange _
:=Workbooks("Job test.xlsm").Sheets("Criteria").Range("A1:A2"), CopyToRange _
:=Range("A1"), Unique:=False
[Code] ......

What this code hopes to achieve is that when I change the value in the LightType dropdown, the Fixtures DB workbook will automatically filter the data once to a different sheet(CLampType), then get only unique values for LampType in column O. I have set up a dynamic range for column O so as to populate my next combobox, LampType.

This should all be fairly simple and straightforward, however I am running into "Run-time error '1004': Clear method of Range class failed." when I try to execute the line to clear the worksheet, and also have an error when I try to filter the data via macro. The strange part is all of this can be done manually without a problem, and moreover I have tried recording the process and using the recorded version. Even stranger yet is that when I add an "on error resume next" before everything, the code works fine but keeps looping and acts finicky(I don't want to simply resort to this as a solution). I have also tried setting this macro up inside the Fixtures workbook instead and calling it from the combobox change, to no avail.

View 1 Replies View Related

Copy Method Of Worksheet Class Failed In Loop Code

Sep 5, 2006

I have an excel sheet being used as a mini database table.Rows = records, columns = fields. I have some VBA to create a copy of base template in the workbook, then populate the new template with the data from a row/record in the db. I currently have about 100 records. After about the 57th record I recieve RT error 1004. "Copy method of worksheet class failed". I think this is becuase excel is running out of memory. My laptop has 1gig of ram, and i have closed all other apps when running the macro.

Is there a way to free up memory while the vba is running, without clearing my "for" or count position which tells the macro to create a new sheet and which row/record in the db to populate the data in the new sheet.

View 5 Replies View Related

Spreadsheet That Allows Users To Select Items From A Validated Data List

Mar 25, 2009

I am making a spreadsheet that allows users to select items from a validated data list. Each item in the list has a numeric value in an adjacent column. When the user is entering data they will select from a drop down of the data list in column "A" and I would like to have the numeric value that corresponds with their selection to then autofill in column "B". I have tried VLOOKUP and IF formulas but cannot seem to get anything to work.

View 9 Replies View Related

Formula To Pull Out Data From A List To Create Class Lists?

May 16, 2014

if there was a way to automatically add each student to a class list as their information is inputted. What i mean is, after input Sally Student in the main enrollment list she would automatically go to the class list for the class she has chosen.

I have attached a sample workbook with my desired results. Basically what i want to do is make this easier for those in charge to get the class lists from the main list without having to copy and past all the time.

The class lists are in the tabs in the workbook.

View 5 Replies View Related

Array Formula: List The Number Of A Specific Class For A Particular Month (any Day)

Dec 30, 2009

I'm having difficulty creating an array formula. In a multi-column sheet, I am looking at a column with classes and a column with a date (in the format 7-Oct-09). I need to list the number of a specific class for a particular month (any day). I have tried the following which gives only the number of classes:
=COUNTIF(A4:A2500,"AA")+COUNTIF(H4:H2500,"10/??/09") and
=SUM((A4:A2500="AA")*(H4:H2500="??-Oct-??")) which gives me 0. Maybe an array formula is not the way to do this.

View 9 Replies View Related

Automatic Auto Filtering: Filter The List And Have A Box For Users To Type In Text

Aug 25, 2006

I have a list of a couple of thousand (and more) individual items. I want to filter the list and have a box for users to type in text (there are no numbers) and the results will be seen automatically reducing in number as more text is entered. (Similar to the Windows HELP files )

eg, typing A (or a) will show all entries beginning with A (without pressing
"Enter" or similar
typing AB will show only entries beinning with AB
typing ABO will show .........I guess you will understand the idea.

I have tried various forms of Filter - Auto and advanced - but still cannot get the spreadsheet to do what I want. Unless I am not doing the Autofilter (or Advanced filter) correctly (I am still a relative beginner!) I still cannot find a way of simply adding letters to a cell or input box and the filtering takes place 'automatically' as the letters are added.

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

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

Share Workbook With "Allow Changes By Multiple Users" Code

Aug 8, 2007

Although i am using VBS, the coding should be similar. I am looking for all Excel files in a folder (WORKING) and determining if they are shared, allowmultipleusers, (WORKING). The problem I am encountering is changing the Excel workbook to a [SHARED] workbook. By that I mean Multiple users can open and make changes. What is the syntax to enable that? As an FYI I can save the [SHARED] workbooks as exclusive (normal), but not the reverse. I have tried Saveas,,,,,,xlshared, but is not working. Here is the VBS code I have (For grins)

Set objShell = CreateObject("Shell.Application")
'Set objFolder = objShell.Namespace("L:Shared Services Stock Rotation ReviewRotations for Review")
Set objFolder = objShell.Namespace("C:Documents and Settingsmhast14DesktopRotations for Review")
Set objFolderItem = objFolder.Self

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objExcel = CreateObject("Excel.Application") ..............

View 3 Replies View Related

Receiving Error In Code "unable To Get The Find Property Of The Range Class"

Apr 26, 2006

I am receiving the error "unable to get the find property of the range class" in my code. I have attached my code and highlighted red where my error is occuring.

On Error Goto ProductionRptEngineListExport_Error
Dim objWrkTmp As Excel.Workbook
Dim ObjWrkshtActive As Excel.Worksheet
Dim objWrkshtTmp As Excel.Worksheet
Dim RngStart As Excel.Range
Dim CurrentRowNum As Long, RowCnt As Long
Dim GroupRowNum As Long, ColCnt As Long
Dim chtChart As Excel. chart
Dim intwrktmp As Integer, intwrktmpTot As Integer, intLastRow As Long
Dim sngwrk As Single

ctlStatus = "Opening Production Report..."

View 2 Replies View Related

Constants As Arrays In Vba?

Apr 16, 2009

Can you declare a const as an array in VBA? For example, let's say I wanted to define an array of ORDINALS:

Const ORDINALS(0 to 9) = ("0th","1st","2nd","3rd","4th","5th","6th","7th","8th","9th")

View 2 Replies View Related

Select Constants

Aug 3, 2007

Can a macro be provided for selecting cells (including hidden) in the active sheet which are :

1. Totally consants ie not used in formula either in same sheet or other sheets

2. Constants ie figures used in formula in the same sheet and/or other sheets

View 9 Replies View Related

Using Constants In Same Module

Oct 15, 2009

I declared a constant like so:

Public Const iFirstRow As Integer = 6

I figured that any time I used this, at least in the same module, its value would be 6, but it was 0.

I changed it to ModuleName.iFirstRow, which seemed to set it straight.

Is this just how it is, or am I doing something wrong that is preventing me from using it without the module name?

View 9 Replies View Related

Constants Are ($) Variables Are?

Apr 14, 2007

While $ are constants for cells what is the symbol for variables? I guess when I dragged a formula down rows a certain number did not increase so I had to manually up each one as I went down the rows.

View 4 Replies View Related

Sum Formula With Constants

Jun 23, 2007

I have a Excel budget spreadsheet. I need a running formula I can copy and paste to other month cells.


=SUM(B11+B4+C11-D11) Interest(B4), interest1(C11) and pmt(D11) are constants. The formula I am using works but it won't copy and paste.

View 3 Replies View Related

Copyrights 2005-15, All rights reserved