+ Reply to Thread
Results 1 to 5 of 5

Pass values of UserForm TextBoxes to 2D Array

  1. #1
    Forum Contributor
    Join Date
    07-13-2017
    Location
    Hong Kong
    MS-Off Ver
    MS Office 365
    Posts
    469

    Pass values of UserForm TextBoxes to 2D Array

    Hi all,

    I need to pass values from my UserForm's TextBoxes to a Named Range as a two dimensional array and it just doesn't seem to work!!

    I am using below code to get the values

    Please Login or Register  to view this content.
    My UserForm is created dynamically and looks as follows:

    fdsfds.PNG

    When I run the code I would get errors if the textbox is blank, hence I used "On Error Resume Next". With such error handling it creates the following named array:

    Please Login or Register  to view this content.
    It somehow seems to "ignore" the first two columns "PF" and "FAL", but I don't know why??

    If I instead use

    Please Login or Register  to view this content.
    It works just fine, but it's not a two dimensional array

    I want to use such named array to get certain values in my workbook formulas

    e.g.

    Please Login or Register  to view this content.
    result = 75
    Last edited by esbencito; 11-26-2018 at 05:08 AM.

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    UK
    MS-Off Ver
    2016 primarily
    Posts
    4,121

    Re: Pass values of UserForm TextBoxes to 2D Array

    You're only specifying one dimension when populating the array - use both:

    Please Login or Register  to view this content.
    Rory
    Sue, you're shouting at tea

  3. #3
    Forum Contributor
    Join Date
    07-13-2017
    Location
    Hong Kong
    MS-Off Ver
    MS Office 365
    Posts
    469

    Re: Pass values of UserForm TextBoxes to 2D Array

    I did! Just corrected my OP, sorry!

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    UK
    MS-Off Ver
    2016 primarily
    Posts
    4,121

    Re: Pass values of UserForm TextBoxes to 2D Array

    And move the Redim so it's before your loops.

  5. #5
    Forum Contributor
    Join Date
    07-13-2017
    Location
    Hong Kong
    MS-Off Ver
    MS Office 365
    Posts
    469

    Re: Pass values of UserForm TextBoxes to 2D Array

    Quote Originally Posted by rorya View Post
    And move the Redim so it's before your loops.
    OMG!!! That's it!! Added the second loop a lot later and totally forgot about Redim!! Always good to have an expert double-checking each line of code. Thanks!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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