+ Reply to Thread
Results 1 to 20 of 20

How to read & compare integers values in a String?

  1. #1
    Registered User
    Join Date
    01-30-2020
    Location
    Germany
    MS-Off Ver
    Excel 2016
    Posts
    34

    How to read & compare integers values in a String?

    I am a VBA novice trying to create a program.

    I need some help with a a vba program because I am facing some challenges with reaching the requirement that is need.

    Could anyone help me achieve the required output for C24 & D24? Feel free to modify the code if required.

    Required outputs are listed in the excel file. Thank you.
    Last edited by trippyninjas; 03-09-2020 at 09:09 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    07-14-2017
    Location
    Poland
    MS-Off Ver
    Office 2010
    Posts
    528

    Re: How to read & compare integers values in a String?

    I did for the D20: D22 range.
    For C20: C22 code lines commented.
    Adapt to your needs.
    Please Login or Register  to view this content.
    Last edited by maras_mak; 03-09-2020 at 10:32 AM.
    Best Regards,
    Maras.

  3. #3
    Registered User
    Join Date
    01-30-2020
    Location
    Germany
    MS-Off Ver
    Excel 2016
    Posts
    34

    Re: How to read & compare integers values in a String?

    I apologize. I have made a mistake uploading the worksheet with the outdated property value.

    Here is the excel sheet with the updated property values.

    Could you use this updated worksheet with the updated properties instead?

    Thank you!
    Attached Files Attached Files
    Last edited by trippyninjas; 03-09-2020 at 08:44 AM.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to read & compare integers values in a String?

    UDF, use in cell like
    C24:
    =MinMin(C20:C22)

    D24:
    =MaxMax(D20:D22)

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-30-2020
    Location
    Germany
    MS-Off Ver
    Excel 2016
    Posts
    34

    Re: How to read & compare integers values in a String?

    Hello everyone. As a VBA novice, I don't really understand a lot of the syntaxes.

    Could you upload the worksheet with comment lines? That way i can better undestand the codes better.

    Thanks!

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to read & compare integers values in a String?

    What do you not understand?

    Do you want to know how to use it? or what each line does?

  7. #7
    Registered User
    Join Date
    01-30-2020
    Location
    Germany
    MS-Off Ver
    Excel 2016
    Posts
    34

    Re: How to read & compare integers values in a String?

    That is correct. I would like to understand the code better because I need to explain the program as well. Could you use the RangeExe2 file and reupload it here? I appreciate it

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to read & compare integers values in a String?

    Then just point out the line(s) that you don't understand.

    I don't know how well you know about VBA, so no idea to "explain", if you do not understand any one line of the code.

  9. #9
    Registered User
    Join Date
    01-30-2020
    Location
    Germany
    MS-Off Ver
    Excel 2016
    Posts
    34

    Re: How to read & compare integers values in a String?

    Ah you have a good point. I will highlight the lines that I am unable to understand and get back to you.

    *One issue* I have pasted your code into the worksheet but it still produces the same result.. instead of 1kHz - 5Mhz for C24, it is still displaying 1kHz-10Mhz.

    What should i do?

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to read & compare integers values in a String?

    VBA code should be placed in a Standard code module, not a worksheet code module.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    01-30-2020
    Location
    Germany
    MS-Off Ver
    Excel 2016
    Posts
    34

    Re: How to read & compare integers values in a String?

    Amazing. it works now. Thank you very much.

    I have a similar requirement here but with voltage. Could you help me out please?

    Thank you!

    Best regards,
    Chris
    Attached Files Attached Files

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to read & compare integers values in a String?

    No need of vba

    formula;
    C24:
    =MAX(LEFT(C20:C22,LEN(C20:C22)-3)+0)&"V/m"
    Confirm with Ctrl + Shift + Enter (Array formula entry)
    The copy to the right.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  13. #13
    Registered User
    Join Date
    01-30-2020
    Location
    Germany
    MS-Off Ver
    Excel 2016
    Posts
    34

    Re: How to read & compare integers values in a String?

    Hello jindon!

    Unfortunately, i require output to display the highest value when 1 or more button is pressed. *Could be A + B or A + C*
    Therefore, not every button will be pressed together in every case. The formula you provided works only when all buttons are pressed together.

    I'm sorry i did not specify that earlier. :P

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to read & compare integers values in a String?

    What do you mean by
    *Could be A + B or A + C*
    No idea about what you are trying to do.

  15. #15
    Registered User
    Join Date
    01-30-2020
    Location
    Germany
    MS-Off Ver
    Excel 2016
    Posts
    34

    Re: How to read & compare integers values in a String?

    In the program, there are 3 buttons (Range A, Range B & Range C).

    The code only works when all 3 buttons are pressed together.

    In a scenario where only button Range A and Range C are pressed together, what should i do to display the highest value in C24 & D24?

    Thank you

  16. #16
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to read & compare integers values in a String?

    Still not clear.

    What do you want to happen when
    1) Range A pressed.
    2) Range B pressed
    3) Range C pressed
    4) Range A + Range B pressed
    etc.etc...

  17. #17
    Registered User
    Join Date
    01-30-2020
    Location
    Germany
    MS-Off Ver
    Excel 2016
    Posts
    34

    Re: How to read & compare integers values in a String?

    The user is free to press any 2 buttons or all 3 at the same time.
    Based on which buttons are pressed, column C20 - D22 will display the of the values (from Properties) accordingly.

    The program will compare the values inside of C20 - C22 and display the highest value in C24. The same for D24.

    Pressing only 1 button is not required because theres nothing for the program to compare. However, what happens if a user presses

    (Range A + Range B) as you have stated or (Range A + Range C) etc.. ?

    then C24 should be able to compare the values and display the highest value as the requirement suggests.
    Last edited by trippyninjas; 03-10-2020 at 05:31 AM.

  18. #18
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to read & compare integers values in a String?

    Then change the formula to

    =IF(COUNTA(C20:C22),MAX(IF(C20:C22<>"",LEFT(C20:C22,LEN(C20:C22)-3)+0))&"V/m","")

    Confirm with Ctrl + Shift + Enter (array formula entry)

  19. #19
    Registered User
    Join Date
    01-30-2020
    Location
    Germany
    MS-Off Ver
    Excel 2016
    Posts
    34

    Re: How to read & compare integers values in a String?

    Hello jindon! I have to apologize for the long hiatus. The formula works well.

    Unfortunately i'll have to make some admendments with the requirement. Could you help me amend the modules to meet the requirement? Thank you.
    Attached Files Attached Files
    Last edited by trippyninjas; 03-18-2020 at 03:18 AM.

  20. #20
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,523

    Re: How to read & compare integers values in a String?

    C24
    =IF(COUNTA(C20:C22),MinMax(C20:C22),"")
    copy to the right.
    Please Login or Register  to view this content.
    You are not allowed to create duplicate thread.
    https://www.excelforum.com/excel-pro...in-a-cell.html

+ 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. Read and compare subject string from new received email in Outlook
    By alexgoaga in forum Outlook Formatting & Functions
    Replies: 0
    Last Post: 08-23-2017, 04:44 AM
  2. Using string and integers in textbox
    By JennaM in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-06-2017, 10:55 AM
  3. [SOLVED] read values from cells and compare them with preset values
    By AHMED_GWAD77 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-24-2016, 02:16 PM
  4. modify UDF ConCatIf to read and compare one of two alternative values
    By Narayan~ in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 04-15-2013, 02:29 PM
  5. Sum integers in string
    By jordan2322 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-19-2012, 09:17 AM
  6. How do I read data from one column, compare it to the values one next to it?
    By kih1251 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-10-2012, 06:15 PM
  7. compare integers
    By philmetz in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-11-2009, 07:33 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