+ Reply to Thread
Results 1 to 15 of 15

tricky if command

  1. #1
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    tricky if command

    Hi,

    Can anyone help out. I would like to add the contents of Combobox 7 and Combobox23 and the number 30 if the contents of combobox5:

    is 75,
    35 if the contents Combobox5 is 127 or
    30 if the Contents of Combobox5 is 75

    The answer to be placed in Combobox19

    Any help would be gratefully received.

    This code has been greatly assisted by Kenneth.




    Please Login or Register  to view this content.
    Last edited by bralew; 10-10-2016 at 05:39 AM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: tricky if command

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: tricky if command

    One small tweak, to prevent adding duplicate items in ComboBox19:
    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  4. #4
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: tricky if command

    Thanks chaps

  5. #5
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: tricky if command

    Hi the answer is coming out as 30, but it should be Combobox7 (71) plus combobox23 (71)plus 30 equals 172?????

  6. #6
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: tricky if command

    select 54sq Square at the first user form

    Select Hub A, in the Hub box and 75 in the Drop Arm centres box and the H factor box reports 30 instead of 142?
    Last edited by bralew; 10-11-2016 at 03:48 AM.

  7. #7
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: tricky if command

    How are you reaching your required outcome of 142?

    In the scenario you describe, ComboBox7 has a value of "A 71", and ComboBox23 has a value of "A 71". These are both strings, so cannot be added up as a number.

  8. #8
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: tricky if command

    I'm looking to achieve 71 + 71 to equal 142.

    142 + 30 (for case 75) to equal 172

    The 71 and 71 values comes from the addition of contents of combobox7 and combobox23 the 30 is a thickness measurement that I have to include. I know its horribly complicated :-(

  9. #9
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: tricky if command

    So you want to convert the strings to values - removing the "A " part, and only considering the "71" ?

    Looking at your combobox list values, it appears it would only ever be 41 or 71 - so you could change the code to:

    Please Login or Register  to view this content.
    Can I offer a couple of bits of advice?
    1. Use Select Case throughout your code, instead of If statements.
    2. Rename your forms and form controls to something more meaningful.

  10. #10
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: tricky if command

    Ok thanks Olly, I'll give it a whirl now

  11. #11
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: tricky if command

    Thank you Olly, its worked fine. I can now edit with extra cases of which there are many.
    One more thing, I have the correct 172 I just need to multiply this figure by 2. I've put this in (see below) but I get 314 instead of 344.
    I suspect that I've got the code wrong





    Please Login or Register  to view this content.

  12. #12
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: tricky if command

    Maybe:
    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  13. #13
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: tricky if command

    i GOT IT::



    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    07-05-2016
    Location
    cardiff
    MS-Off Ver
    2010
    Posts
    787

    Re: tricky if command

    Thanks Again Olly, You've been a great help and I'm very grateful.

    and to you TMS, cheers

  15. #15
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,463

    Re: tricky if command

    You're welcome. Thanks for the rep.

+ 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. A tricky one (for me anyway)
    By johnogolf in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 10-26-2012, 10:27 AM
  2. this is a tricky one
    By cjohnsen in forum Excel General
    Replies: 3
    Last Post: 10-13-2006, 08:34 AM
  3. Tricky Tricky episode 2!!!
    By mhax in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-21-2006, 10:15 AM
  4. Tricky Tricky!
    By mhax in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-20-2006, 02:10 PM
  5. A Tricky One......
    By nevi in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-18-2006, 09:10 AM
  6. This might be a little tricky......
    By nevi in forum Excel General
    Replies: 2
    Last Post: 06-16-2006, 11:22 PM
  7. Tricky maybe
    By Frazcmankfar in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-18-2005, 12:25 PM
  8. [SOLVED] Help Please! (This one is a bit tricky)
    By Dean Goodmen in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-25-2005, 09:00 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