+ Reply to Thread
Results 1 to 5 of 5

Sort 3 textboxes to get an order for a specific formula

  1. #1
    Registered User
    Join Date
    10-26-2015
    Location
    Belgium
    MS-Off Ver
    2013
    Posts
    36

    Sort 3 textboxes to get an order for a specific formula

    Hi,
    I'm fairly new to VBA programming and I stumbled upon a problem concerning sorting my data from textboxes from small to big and use them in a formula to calculate the girth of a box. (Girth formula is [(adding 2 smallest dimension)*2+largest dimension])

    The problem is, I keep having an error sorting my data before i can even use this formula. What I have now is:


    Please Login or Register  to view this content.

    Thanks for helping. I've already been searching for this for about a week at the moment (and about 1 day on this forum).
    Last edited by stielo; 10-27-2015 at 10:25 AM. Reason: Solved

  2. #2
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Sort 3 textboxes to get an order for a specific formula

    Couple things:
    • Small1 2 and 3 are not objects, and therefore don't have .Values
    • AFAIK, .Small is a WorksheetFunction, not Application
    • .Small requires that you pass in an array
    • You don't want to use quotes around W, D, and H. Using quotes means they are strings (i.e. you're trying to pass in the letter W, instead of the value that W represents)
    • I don't see a point in Dim'ing your variables as Variant, they are going to be that by default.


    Try:
    Please Login or Register  to view this content.
    Last edited by walruseggman; 10-26-2015 at 12:11 PM.
    I'm interested in starting a career working with VBA, if anyone knows of any opportunities!

  3. #3
    Registered User
    Join Date
    10-26-2015
    Location
    Belgium
    MS-Off Ver
    2013
    Posts
    36

    Re: Sort 3 textboxes to get an order for a specific formula

    Thanks for offering your advice.
    With the WorksheetFunction.Small, I get an error stating I can't use the worksheetfunction.
    With application.small, this error is solved.
    The code now however gives an error on the formula (error number 13, types don't match)

    Anyway, thanks for giving the explanation on how you changed it. this will certainly help me improve my VBA skills

  4. #4
    Forum Expert
    Join Date
    08-28-2014
    Location
    Texas, USA
    MS-Off Ver
    2016
    Posts
    1,796

    Re: Sort 3 textboxes to get an order for a specific formula

    I'm guessing that text boxes 39 to 40 .Values are probably strings. Try to cast them as longs.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-26-2015
    Location
    Belgium
    MS-Off Ver
    2013
    Posts
    36

    Re: Sort 3 textboxes to get an order for a specific formula

    Thanks for helping out. It works like a charm like this.

+ 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] Formula to Sort the Data in Descending Order
    By Ankit_Kumar in forum Excel General
    Replies: 8
    Last Post: 04-27-2015, 07:48 AM
  2. [SOLVED] Dynamic formula for specific numbering order
    By JO505 in forum Excel General
    Replies: 14
    Last Post: 03-07-2015, 01:13 AM
  3. Need formula to follow a specific order, please help.
    By Darker0ne in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-09-2014, 04:43 AM
  4. [SOLVED] Sort specific visible sheets in an order according to cells in each sheet
    By Comisar in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-14-2013, 06:57 PM
  5. Replies: 4
    Last Post: 03-14-2013, 09:14 PM
  6. Automatically Generate Order Form based on Textboxes
    By emzipoo4u in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-21-2012, 04:21 PM
  7. [SOLVED] Set tab order for textboxes
    By Sandy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-28-2005, 09:30 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