+ Reply to Thread
Results 1 to 27 of 27

How do i compare properties and display it?

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

    How do i compare properties and display it?

    I am currently stuck with my program because my knowledge of VBA is still very limited.
    It is a basic interface where a summary will display the properties of different ranges when pressed.

    I am having trouble displaying compared the result in the summary column.

    I have uploaded the excel file and also pasted my code here. Could anyone help me?

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by trippyninjas; 02-14-2020 at 05:09 AM.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How do i compare properties and display it?

    Please Login or Register  to view this content.
    Attached Files Attached Files
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

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

    Re: How do i compare properties and display it?

    Thank you for your response! I appreciate your modification of the the code. It looks much better now. However, the summary column should only display the 1 lowest range & the 1 highest range for the selected choices. I wonder if that is possible? Thank you

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,616

    Re: How do i compare properties and display it?

    Try such code (event handler) in the same module
    It's now only dealing wityh columns B and C. Column D would be very similar to column C, but column E would be more complicated.
    But let's start from checking if this produces desired output for columns B and C:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Best Regards,

    Kaper

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

    Re: How do i compare properties and display it?

    Yes! this is the exact outcome that I need. However, the code is in German. Is it possible to change it to English? Thanks!

  6. #6
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,616

    Re: How do i compare properties and display it?

    The code is universal. Only the variables are named with German names. The code would work exactly the same if names of variables were variable1, variable2, etc. So you can change these names yourself using Change option - ctrl+H

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

    Re: How do i compare properties and display it?

    Ah i see. Thank you so much. I'm still struggling at column E. It is so annoying,

  8. #8
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How do i compare properties and display it?

    I cannot post my code.

    Please see the attachment.
    Attached Files Attached Files

  9. #9
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,616

    Re: How do i compare properties and display it?

    As I understand, desired output for E24 when all ranges are selected could look like:
    Car (Range A, Range B) / Apple (Range C)
    Below is sample code for this task (I left the rest of the code (almost) untouched because I like structural programming used by mehmetcik.
    Please Login or Register  to view this content.
    it can be called at the end of MinMax sub:
    Please Login or Register  to view this content.
    In the attachment you will find a bit more advanced version, which shows only Item without listing Range(s) if all displayed Item types are the same.

    Please Login or Register  to view this content.
    Also included in code some measures to use large H in Hz abbreviation. like kHz, MHz, etc. but don't list it here - see the code in attachment.
    Attached Files Attached Files

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

    Re: How do i compare properties and display it?

    Thank you Kaper & mehmetcik for the great help. B24 & E24 is the exact outcome i was looking for.
    Your codes have improved my way of programming and I am learning alot from your code as a beginner.

    I am now facing a slight issue. The column C24 & D24 should display the range instead of the highest/lowest Hz. The C24 outcome in "Range.xslm" is the desired outcome. However, from Range2 onwards it became slightly different.

    What should i do? Thanks
    Last edited by trippyninjas; 02-19-2020 at 05:39 AM.

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

    Re: How do i compare properties and display it?

    *Update*

    This was the code from "Range.xlsm" that provided the desired C24 outcome.

    However, when i modify the code for D24, it gave a incorrect outcome.

    Please Login or Register  to view this content.

  12. #12
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,616

    Re: How do i compare properties and display it?

    The code for D24 shall look not for the smallest but for the largest value,
    so not 10^307 as initial value but for instance 0 or -10^307
    and of course checking if left limit (or may be one shall look on a right limit) is larger then largest so far value.

    But as there is already nicely working MinMax procedure, it will be enough/better to change only parts of it, which are responsible for writing results into C24 and D24.
    For instance that way:
    Please Login or Register  to view this content.
    Attached Files Attached Files

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

    Re: How do i compare properties and display it?

    The code now works perfect. However, i am finding some difficulty in understanding the code. Most of the unknown syntaxes i will be able to find on Google but there are lines that still leaves me confused..

    What and where is MinMax declared?

    Please Login or Register  to view this content.
    Where is Cells(A,3)

    Please Login or Register  to view this content.
    what is NV/OV?

    Please Login or Register  to view this content.
    Could you also explain how this is derived?

    Please Login or Register  to view this content.
    I have also noticed that you have included both private subs (Show_by_type & Show_by_type_old) is that required?

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    It would be of great help if there are extra explanation comments provided

    Pardon my ignorance and questions. I personally find the first version (before MinMax) easier to understand. However, i'm always keen on learning a higher level of programming.

    My VBA skills are limited but i am trying hard.

    Thank you for your time!
    Last edited by trippyninjas; 02-20-2020 at 04:52 AM.

  14. #14
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How do i compare properties and display it?

    I cannot post the Code.

    I have inserted some comments in the code for you.
    Attached Files Attached Files
    Last edited by mehmetcik; 02-20-2020 at 06:03 AM.

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

    Re: How do i compare properties and display it?

    Great explanation. May i also clarify the following:

    What is the reasoning behind the (-17) ?
    Please Login or Register  to view this content.
    For Subroutine MiniMax is there a specific reason why the Data A is = 20? Is it up to the user?

    If i want to add multiple buttons do i just simply add more MiniMax subroutines with a increment of 1?

    Thanks for the swift reply mehmetcik. I appreciate it!

  16. #16
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How do i compare properties and display it?

    Hi.

    On the Programs Sheet you Data is in B20, B21 or B22

    However on the Properties Sheet this Data links to C3, C4, C5

    So B20 links to C3 20 - 3 = 17. The 17 allows us to link the data on both sheets simply.

    In MiniMax A =20 or A = 21 or A = 22 depending on which button you press. I used 20 as an example.

    That is the beauty of the solution. you can have literally hundreds of buttons using the same code.


    Try this:

    On a new Sheet

    Formula for A1 ="Private Sub Range" & CHAR(INT(ROW()/5)+65) &"_Click()"
    Formula for A3 ="MinMax (" & INT(ROW()/5 +20) &")"
    Formula for A5 End Sub

    Copy A1 to A5

    Paste into A1 to A40

    Now for the neat bit.

    Copy A1 to A40 and paste into a visual basic module.

    Please Login or Register  to view this content.

  17. #17
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,616

    Re: How do i compare properties and display it?

    -17 is the difference between locations of ranges in both sheets. The ranges start from row 3 in Properties and from row 20 in Program

    A=20 for first range is because output goes to row 20 for first range and so on.

    Basically - yes, you can add more ranges. Just note that you will probably need to move the summary from row 24 down (or may be above?)

    As for explanation to last sub:

    Please Login or Register  to view this content.
    One last comment.

    After some training you got here, I'd think of different approach than creating dozens of command buttons.
    Some parts of code could be reused. some just slightly modified.
    I'd load into one listbox a list of all available ranges
    then the button would transfer the selected (in inbox) range into the table, writing it into first free row, and remove the selected range from the listbox
    the second button wouuld do a reset - clearing output table and loading back all ranges into listbox.
    The buttons and the listbox could be either on the worksheet (as they are now - and I'd probably opt for this solution) or cold be on a Userform to have a more "professional look".

    PS.
    Please Login or Register  to view this content.
    is no longer used, and can be removed from the code (as was Show_by_type_old)
    Last edited by Kaper; 02-20-2020 at 08:12 AM. Reason: Please noted I was writing not seeing the last (one above) post :-)

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

    Re: How do i compare properties and display it?

    Wow after reading every explanation i was able to understand the code better. Now i'd like to ask:

    Since the MinMax (?) subroutine reads the list properties that are being layed out horizontally in rows, what should i do in a scenario where my properties are being listed vertically instead, but i still want to present my output horizontally at the same time? (Just like the current version)

    The reason why i ask is because i am starting to understand the potential of MinMax but i still don't have the full understanding of it. Maybe with some examples i'd be able to have a better understanding and idea.

    Here is a updated version where i have changed the Properties layout from horizontal to vertical. It'd be great if you can show me what to amend in the code in order to achieve the same result. Thank you.

    - In reponse to Kaper's last comment:

    I am definitely keen to learn if there is a way to make my interface look more professional. I've looked up tutorials on Userforms before but my knowledge was only limited to a few simple tasks. I definitely need some help. If you have any suggestions or examples on how to make the Interface look better feel free to use my program as a example. I look forward to it!

    Finally i'd like to say, it is so much easier to learn from completed working codes instead of writing one from scratch. It would've definitely taken me months to come up with something like this with just the Internet and no proper guidance. I am so glad to have discovered this forum and more importantly, receive help from professionals such as yourselves. Thank you guys so much.

    Regards,
    Christian
    Attached Files Attached Files

  19. #19
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How do i compare properties and display it?

    Please Login or Register  to view this content.

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

    Re: How do i compare properties and display it?

    Thank you for your help! The codes have produced the results that i needed. This thread will be considered solved.

    Perhaps you guys are familiar with graph creation in vba as well? If yes i will now require some help as well. Thanks!

    https://www.excelforum.com/excel-pro...r-touches.html

  21. #21
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,616

    Re: How do i compare properties and display it?

    As the solution works, it would be a good idea to mark thread as Solved. (not just mentioning it in the text).
    Above your first post you will find Thread Tools to do it.

    It would be lovely if you could also "add some reputation" to those who helped by clicking a small star icon in lowerleft corner of our posts and then confirm in pop-up message (note that some browsers block this pop-up).
    As opposite to many other sites, you can grant reputation to more than one users/posts.
    Attached Images Attached Images

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

    Re: How do i compare properties and display it?

    Good day everyone,

    I require to make some slight changes. Hence, i have decided to reopen this thread. I am now facing a little trouble with using the MinMax function.

    I have uploaded the excel sheet with the new required output listed inside. All of the codes remains untouched from Zesyt5 .
    What is different from in this new program is that the Properties are listed in a slightly more complicated format. e.g Merged cells etc.


    I hope you guys are still willing to lend a hand. Thank you!

    Best regards,

    Christian
    Attached Files Attached Files
    Last edited by trippyninjas; 02-28-2020 at 04:37 AM.

  23. #23
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: How do i compare properties and display it?

    Ok. Try this Version.
    Attached Files Attached Files

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

    Re: How do i compare properties and display it?

    Hi Mehmetcik,

    unfortunately there is an error in the code. A debug error pops up when i click on either B or C.

    error.PNG

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

    Re: How do i compare properties and display it?

    Hello Kaper,

    Could you help me modify one of the codes you have wrote awhile back to produce a updated requirement? All of the details are inside the file.

    Always appreciate your help. Thank you

    Best regards,
    Chris
    Attached Files Attached Files

  26. #26
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,616

    Re: How do i compare properties and display it?

    The requirement is ill defined. I fyou need low values from both lower and upper limits then from

    1khz-10Mhz
    200Mhz-6Ghz
    80Mhz-6Ghz

    the result will be
    1khz-10Mhz

    not
    1khz-6Ghz

    200Mhz-20Ghz
    for highest range seems to be OK as it's combination of
    200Mhz-6Ghz
    and
    150Mhz-20Ghz


    PS. Perhaps you don't care but the units are
    Hz
    kHz
    MHz
    GHz
    ...

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

    Re: How do i compare properties and display it?

    Yes, you are right. Unfortunately, I have uploaded the file with the outdated property values.

    Here is the excel worksheet with the updated property values.

    Apologize for the inconvenience caused.

    Best regards,
    Chris
    Attached Files Attached Files

+ 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. display properties
    By chriswrcg in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-13-2017, 07:49 AM
  2. Replies: 2
    Last Post: 08-29-2015, 10:58 AM
  3. Cannot Display Tooltip in Properties
    By BLLMRC in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-16-2013, 08:19 PM
  4. Do not display of Document Properties on start up.
    By W Truong in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 09-20-2012, 06:15 PM
  5. Display file properties in cells?
    By davidm_uk in forum Excel General
    Replies: 5
    Last Post: 06-21-2011, 02:54 PM
  6. Replies: 1
    Last Post: 05-12-2009, 04:39 AM
  7. Formatting display properties on all sheets
    By AVR in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-18-2007, 04:59 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