+ Reply to Thread
Results 1 to 4 of 4

Variable class, reuse logic per class

  1. #1
    Registered User
    Join Date
    07-26-2010
    Location
    NL
    MS-Off Ver
    Excel 2016
    Posts
    74

    Variable class, reuse logic per class

    Hi,

    I am trying to read an export file and count some instances based on their department name.
    I wish to make te same types of count (based on some logic) for each class (e.g. department), there are 20+ departments so I would not like to repeat the logic instead of copying the logic code for every class.

    Here is an simplified version of the the code where i reuse the code on every class?

    Please Login or Register  to view this content.
    Can anyone help me in right direction?

    TIA

    AB

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: Variable class, reuse logic per class

    Perhaps just a third object:

    Please Login or Register  to view this content.
    Rory

  3. #3
    Registered User
    Join Date
    07-26-2010
    Location
    NL
    MS-Off Ver
    Excel 2016
    Posts
    74

    Re: Variable class, reuse logic per class

    Thanks Rorya for the quick response, that got me in the right direction.
    This solution results in a nested ElseIf formula 20 levels deep, so i would like to populate de class from a reference table (containing two columns, the search value and the class name)

    Please Login or Register  to view this content.
    Do you have any idea why I can't adress the 'D class' with the string that is found with the code show above? (it results in an Errer 13, Type do not match)

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    Re: Variable class, reuse logic per class

    That just won't work in VBA.

    You might want to look at using a Dictionary or Collection to hold all the class instances so that you can refer to them by name.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Class Module Events : How to refering to individual class members
    By kev_ in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-29-2020, 06:27 AM
  2. Replies: 1
    Last Post: 02-15-2020, 10:36 AM
  3. [SOLVED] Function Referencing An External Class When The Class Is Not Referenced
    By Dal123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-29-2018, 01:49 PM
  4. Class Module to design a class based on an autoshape (arrow)
    By BluesEnd in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-18-2017, 07:23 AM
  5. “= 1st class’ lower class limit + class width"
    By CheeseFace in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2016, 08:21 PM
  6. [SOLVED] Class Newbie question #2 - Check if Class already loaded/set?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-16-2014, 06:59 PM
  7. [SOLVED] ComboBox class .AddItem filled in class module
    By Jacques Grobler in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-03-2012, 05:48 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1