+ Reply to Thread
Results 1 to 9 of 9

Command button to toggle Celsius (°C) and Fahrenheit (°F) conversion

  1. #1
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Command button to toggle Celsius (°C) and Fahrenheit (°F) conversion

    I need a command button to toggle back and forward "Celsius (°C)" and "Fahrenheit (°F)", These text will show on the button opposite to corresponding values.
    Example: If values are in °C, the command button should text "Fahrenheit (°F)"; for °F button should text "Celsius (°C)".
    Once the switch back from Fahrenheit to Celsius, D1 will rename to Celsius (°C).

    Below code is came from another post, I do not know to link.


    Please Login or Register  to view this content.

    Thanks
    Last edited by zbor; 10-13-2012 at 11:09 AM.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,058

    Re: Command button to toggle Celsius (°C) and Fahrenheit (°F) conversion

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Never use Merged Cells in Excel

  3. #3
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,058

    Re: Command button to toggle Celsius (°C) and Fahrenheit (°F) conversion

    Is thsi what you want?

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by zbor; 10-13-2012 at 11:39 AM.

  4. #4
    Forum Contributor
    Join Date
    04-03-2011
    Location
    India
    MS-Off Ver
    Excel 2015
    Posts
    122

    Re: Command button to toggle Celsius (°C) and Fahrenheit (°F) conversion

    Hi,

    Can this be done at userform level like

    Example : Celsius (°C) -54 to converts to 98 Fahrenheit (°F)

  5. #5
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,058

    Re: Command button to toggle Celsius (°C) and Fahrenheit (°F) conversion

    Welcome to the Forum, unfortunately:

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.

  6. #6
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Command button to toggle Celsius (°C) and Fahrenheit (°F) conversion

    I supposed to attach a xlsm file with code and values; I forgot, sorry.

    VBA works. Instead of "convert" button, is that possible to show
    "Convert to °C" on the button, if the temperature values are in Fahrenheit?

    Click the "Convert to °C" button again then button will rename to "Convert to °F",
    VBA will convert the Fahrenheit values to Celsius values.

    I have seen this being done in dual language web site converting between English and French.
    The text shows French, the button shows "English".

    In my spread sheet, the heading in D1 will noy be shown in white text to hide. Then I use if function
    to check D1, to enter "°C" or "°F" after the temperture values.

    Thanks

  7. #7
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,058

    Re: Command button to toggle Celsius (°C) and Fahrenheit (°F) conversion

    I thought on that and I try to make it that way.
    However, a VBA don't return me what I would expect.

    I've used NBVC approach from here: http://www.excelforum.com/excel-gene...=1#post2245810

    And I would expect to get button name.
    But I get Button 2 instead. Or any other KIND OF shape and number.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  8. #8
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,058

    Re: Command button to toggle Celsius (°C) and Fahrenheit (°F) conversion

    Also I got this as result for other approaches:

    Please Login or Register  to view this content.
    I hope somebody has some other idea of where is going wrong.

  9. #9
    Forum Contributor
    Join Date
    10-03-2012
    Location
    USA
    MS-Off Ver
    2010
    Posts
    496

    Re: Command button to toggle Celsius (°C) and Fahrenheit (°F) conversion

    Thanks of your effort. I hope I do not make it very complicate.
    I wish I have 5% of your knowledge in VBA. I am starting to learn
    VBA. How these two codes ("Convert" and "shape_name" merge together?
    The new button will replace the "Convert" button.

    Thanks Again

  10. #10
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,058

    Re: Command button to toggle Celsius (°C) and Fahrenheit (°F) conversion

    First of all, what MsgBox return you as result when you click on Celsius button?
    If result is "Button 2" no matter what's name of it, then this part won't work, so no use of it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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