+ Reply to Thread
Results 1 to 6 of 6

adapt userform loop using control name containing variable for worksheet activex controls

  1. #1
    Registered User
    Join Date
    02-22-2014
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    3

    adapt userform loop using control name containing variable for worksheet activex controls

    Hi all,

    First time posting - I have already gotten a lot of my questions answered here - thanks!

    The following code works great to save data from a userform to a database on a worksheet; where my control names are CTRL1, CTRL2 etc. But I haven't figured a way to adapt the code for activex controls I have put on another worksheet(sheet 6) in the same workbook. Any ideas how to loop thru? It does not recognise any combinations I've tried using say: sheet6.OleoObject("CTR" & i).value.
    TIA

    Please Login or Register  to view this content.

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: adapt userform loop using control name containing variable for worksheet activex contr

    How can I test your code without a sample file with userform ?
    If solved remember to mark Thread as solved

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: adapt userform loop using control name containing variable for worksheet activex contr

    Try OLEObjects.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    02-22-2014
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: adapt userform loop using control name containing variable for worksheet activex contr

    Oops- typo there
    Norrie, have tried that - code below shows what I've tried and the errors.................
    Please Login or Register  to view this content.

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: adapt userform loop using control name containing variable for worksheet activex contr

    The error here is caused by not referring to any property of the control.
    Please Login or Register  to view this content.

    This will work.
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    02-22-2014
    Location
    canada
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: adapt userform loop using control name containing variable for worksheet activex contr

    Thank you! You solved it like that!
    I'm learning slowly but this one had me stumped for sure. The loop works perfectly now. Hope this helps someone else along the way.
    Final code below - saves updated record, clears out controls and disables controls:

    Please Login or Register  to view this content.

+ 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. copying the datas along with the activex controls and pasting in another worksheet
    By share knowledge in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-14-2011, 01:30 PM
  2. Programatically change the caption of all Worksheet (ActiveX) controls
    By redseujac in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-04-2011, 01:11 PM
  3. declare variable to hold pointer to ActiveX control
    By dlh in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-11-2010, 07:40 PM
  4. Unable to Display a Userform from an ActiveX Control
    By shivboy in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-10-2007, 03:05 PM
  5. Error 459 on callup of UserForm with ActiveX control
    By pagates in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-19-2006, 09:10 AM

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