+ 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
    481

    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
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    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

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

    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
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,903

    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
    481

    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)

Similar Threads

  1. Replies: 7
    Last Post: 03-12-2017, 03:20 PM
  2. [SOLVED] How to pass a 2D+ array from a procedure to a userform
    By robby.brooks in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-11-2015, 04:43 PM
  3. Getting values from dynamic textboxes on userform in array
    By nasdrasil in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-27-2014, 03:53 PM
  4. [SOLVED] Referencing UserForm TextBoxes in an array?
    By msk37 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-19-2014, 05:22 PM
  5. Replies: 3
    Last Post: 11-05-2014, 01:11 PM
  6. Pass Userform values to UF variables
    By PNCD1957 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-05-2011, 02:18 AM
  7. Pass Userform Values into VBA
    By ChrisKader in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-10-2010, 12:45 PM

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