+ Reply to Thread
Results 1 to 4 of 4

Combining two codes into one

  1. #1
    Registered User
    Join Date
    11-08-2017
    Location
    Lithuania
    MS-Off Ver
    2010
    Posts
    2

    Question Combining two codes into one

    Hello,

    I am a beginner at Excel VBA, so sorry for stupid questions... I am still learning

    I have two different codes. They each work correctly, but I want to combine them into one, to do a bit different task.

    This code creates Buttons "Green", and when you press it, it opens window with information, on which row that button is.

    Please Login or Register  to view this content.
    Second code is for changing color of the row. I assign it to the button. And then row color changes to green or back to normal, by the push of that button.

    Please Login or Register  to view this content.
    The problem is, that I need button for every row. And I have around 1000 rows...
    So, could you please help me to combine these two codes into one?
    I need that every row would have a button, and that row color could be changed by pressing that button. Also, from the first code, I dont need tat it would pop up a window with row number information.


    Thanks in advance
    Last edited by Richard Buttrey; 11-08-2017 at 12:20 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Combining two codes into one

    Hi and welcome to the forum. Unfortunately your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Since this is your first post I'll add the code tags for you but please remember for the future.)

    However do you really need to add button shapes for each row just to colour a particular row? Wouldn't a sheet double click event be simpler? The double click event could be a 'toggle' which either added or removed the green colour.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    11-08-2017
    Location
    Lithuania
    MS-Off Ver
    2010
    Posts
    2

    Re: Combining two codes into one

    Richard Buttrey, sorry about breaking rule #3, it wont happen again! And thanks for fixing it

    This green color is just half of the story.
    In total I will need four buttons and four colors. They all represent the status of the information in the row. For some rows, color will stay all the time the same. But some rows, regarding on the status, color will have to be changed three times.
    This document, right now is about 650 rows, and every day is getting bigger and bigger (10-20 plus rows a day).
    To save time and mouse clicks, having 4 buttons, in my opinion is the fastest way. Since every row's information status is checked and then marked by one person.

    Would be nice to have something similar like here:
    https://accessexperts.com/blog/2011/...ng-using-code/
    But instead of Access use Excel and VBA.
    Untitled.png

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Combining two codes into one

    Quote Originally Posted by Aqmas View Post
    This green color is just half of the story.
    Hi,

    We often find that when we give an answer to what is a trivial non representative example when the solution is used with the real world data it doesn't work because of of other stuff which is important but hasn't been mentioned!

    It's still not at all clear to me why you actually need 4 buttons on each row.
    Can we go back to basics.
    If as you say the colours of the cells on the rows depend on the status of the cells in the row why not use conditional formats to paint the cells and avoid the need for buttons at all?

    If there is some over-riding reason to have buttons, why not just have four buttons at the top and code them so that they use the active cell row when they are clicked to paint the cells. Better still why have buttons at all when you could (as I said before) use the sheet double click event and detect which of the four columns is being double clicked?

+ 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. Combining 2 codes into 1.
    By mullet40 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-08-2016, 01:31 PM
  2. Call Two Codes from ComboBox
    By zplugger in forum Excel General
    Replies: 2
    Last Post: 01-24-2015, 03:02 PM
  3. combining two vba codes into one
    By Ironman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-16-2013, 01:52 AM
  4. Combining vba codes makes the previous codes broken !
    By MDPLUS in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-26-2013, 10:00 AM
  5. [SOLVED] Combining 2 codes?
    By bjcowen9000 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-19-2013, 02:48 PM
  6. combining codes
    By tweety127 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-18-2008, 06:48 PM
  7. [SOLVED] combining 2 codes
    By steve in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-18-2006, 01:15 PM

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