+ Reply to Thread
Results 1 to 10 of 10

Code not producing a value

  1. #1
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Code not producing a value

    I have copied and pasted this code across from somewhere where the If statement is based on cell values so I know it works. Now it is based on userform values and refuses to produce anything.

    Mtt_Script = Userform
    UoW = Combobox 1
    Letter = Combobox 2
    Sophistciated refers to a Select case range

    Please Login or Register  to view this content.

    It must have something to do with the If statement but I have also copied each criteria from elsewhere in the code where it works and I cannot for the life of me work out why it does not work in this one instance. I cannot see the same two cells referenced in this way elsewhere in the code so it can't be ambigious coding.

    Please, please, please can someone show me the very simple thing I am doing wrong (it's always something simple that catches me out)????????


    ' Sophisticated Letter & Sophistication Test UoW

    Please Login or Register  to view this content.
    Userform is attached
    Attached Files Attached Files
    Last edited by Sc0tt1e; 11-29-2013 at 12:11 PM. Reason: Drop downs on attachment had no values

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

    Re: Code not producing a value

    What is MTT_Script.Letter?

    Is it some sort of additional control that has a Letter property?

    By the way, why aren't you referring to Letter from this piece of code?
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Re: Code not producing a value

    MTT_Script.Letter is Userform1.combobox2

    If I set combobox1 as letter editor doesn't like it, if I leave it as combobox1 it defines my selection for me

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

    Re: Code not producing a value

    I've just had a look at the workbook and the first thing I saw in the code was this.
    Please Login or Register  to view this content.
    UoW and Letter are comboboxes on the userform so you shouldn't have variables with the same name in the code.

    Also, you refer to a ComboBox1 when there isn't a ComboBox1.

    ComboBox1 should be replaced with the name of the combobox which lists 231, 232 etc followed by .Value.

    I think Letter might be the relevant combobox so I've used it in the following code.
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Re: Code not producing a value

    Ah Norie, that's where it's happening, it hasn't defined the Sophisticated and non sophisticated aspects of the Select Case.

    I did this once and it worked perfectly but excel closed all my sheets when I shut down the debug I was running and I lost all my work and am now rebuilding all I have researched and developed today.

  6. #6
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Re: Code not producing a value

    Yep, you were spot on. After your last post I checked and I hadn't referenced the SelectCase up to that point that's why it was all working except this part.

    Someone helped me out with the Case Select and suggested I dim them both so I did, thanks for clarifying. All changed and all working fine

    You are a star, thank you

    How do I mark this as solved now, I couldn't see where to do it?

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

    Re: Code not producing a value

    Did you try the code I posted?

  8. #8
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Re: Code not producing a value

    Yep changed combobox1 to Letters.Value and it produces what I need.

    I got rid of the dim combobox statements but what was the dim strLetter as string you added all about?

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

    Re: Code not producing a value

    It was to do with categorizing the selection made in the combobox Letter.

    I used strLetter as it's a string and so as not to clash with the combobox Letter.

    If you look further down the code I've used strLetter in the If/ElseIfs.

    I also changed MTT_Script to Me, Me refers to the userform.

    PS You should get rid of all that Select/Selection stuff.

  10. #10
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Re: Code not producing a value

    Clearing up the code is defintely on the to do list. For now it works and I am on a deadline so I'll leave it as is for now but once completed I will go through and remove select/selection and bring the multi lines down into one to reduce size and complexity etc.

    I will change the strletter and script to me as that seems a good idea, appreciate all the advice and help

+ 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. I need a code for presence check to check multiple text boxes and combo boxes
    By Lee_wwfc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2013, 01:53 PM
  2. [SOLVED] Vba code to fill check in & check out counts
    By ashfaquebwd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-20-2013, 09:02 AM
  3. [SOLVED] vba code to be correct and check ,vba code to brig data for the same refreince
    By funtastic in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-25-2012, 02:29 PM
  4. [SOLVED] check my code - big ask
    By Little pete in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-06-2005, 02:05 PM
  5. [SOLVED] Just a code check please...
    By ste mac in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-21-2005, 06:06 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