Code to edit module?

Glory

Well-known Member
Joined
Mar 16, 2011
Messages
640
I need to add new code to my module, but I'm not sure how to go about that. Is there a method that allows the user to find the last line of a module and then write to it?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
I'll take a look

Real quick, can an array be filled with object variables? Is there any way that's possible? That would make things a lot simpler I think.
 
Upvote 0
Yes - you can load object variables into an array. Either declare the type or use a variant (which could be loaded with objects of different kinds as well as primitive types):

Dim arr(1) As Workbook '//Holds workbook object variables
Dim arr(1) As Variant '//Holds any kind of variable

Note that you can use collections to hold items as well, and VBScript Dictionaries can hold any kind of object including arrays and other dictionaries.
 
Upvote 0
Dim blank As Checkbox

Dim blanks As New Collection?

Then blanks.add("blank") and blanks(index).method?
 
Upvote 0
This sees to have gotten afield of the thread title, but
Code:
    Dim colChk      As Collection
    Dim ctl         As MSForms.Control
 
    Set colChk = New Collection
 
    For Each ctl In UserForm1.Controls
        If TypeName(ctl) = "CheckBox" Then
            colChk.Add Item:=ctl
        End If
    Next ctl
 
Last edited:
Upvote 0
It's all the same problem.

I have a bunch of checkboxes that are being created on a userform at runtime. The quantity created varies depending on the length of a list in a certain range.

Would you recommend using an object array in a class module to handle their click events? Should I try a collection? Or is there a better approach?

Edit: Also, every tenth checkbox I need a new multipage page. Is there a straightforward way to validate b/10 as an integer (eg something along the lines of IsInt(b/10), which obviously doesn't work)? Tried like "If Not (b/10) Is Decimal Then", I don't know how to use a data type in an expression like that.
 
Last edited:
Upvote 0
It's all the same problem.

I couldn't help running around in circles a little. When somebody lights on one thread but not another and I need the answer to both questions, it makes perfect sense to ask the question where they're looking. I've asked lots of questions that just go unanswered, and this prevents that.

The suggestion you presented is the one that I'd already settled on. Nice and simple, and although ZVI pointed out in that other thread that the method will fail with variables longer than a certain number of bytes, numbers larger than like 30000 or whatever, I know my needs will never take the variable to that size.

Thanks for the input.
 
Upvote 0
Please refer here to understand better why duplicate posts are generally discouraged:
http://www.excelguru.ca/node/7

I'm being a bit too polite. Many regulars will quickly ignore your posts if they see you posting duplicates or cross-posting without advising of the fact (a duplicate thread is in essence a cross post in the same forum). Just for your information - not stating my own judgment on the matter.
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,909
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top