+ Reply to Thread
Results 1 to 5 of 5

VBA call function based on change and bg-color

Hybrid View

  1. #1
    Registered User
    Join Date
    11-13-2024
    Location
    Sweden
    MS-Off Ver
    MS 365 Subscription
    Posts
    6

    VBA call function based on change and bg-color

    Goal:
    To create an interactive savings week schedule where i can alter start/end week, and goal amount. The background will be formatted with blue background and the amount average per week will be added into each cell where it is applicable.

    Example (as picture):
    We have a goal amount of 1000 pounds for a bike. We will try to save money between week 6 and 10 which totally is 5 weeks. Average is 200 pounds per week, which is displayed in the table with blue background of every cell with an amount.

    Status:
    I made the background change with conditional formatting so when i entered week_Start and week_End I will get the blue area as in the picture. What is still missing is the average amount per week.

    Idea:
    My idea would be to keep the conditional formatting and when any of the numbers within the red border are changed, the function will return a value, amount_Goal/(week_End-week_Start+1), for each cell in the schedule with that specific bgcolor. How would this be done in VB? I have tried for hours.. or is there any other better way to solve it, and if so, how? If it is possible, i would like to be able to add more savings goals underneath the one in the example to be applied for different tasks. My VB knowledge is extremely limited, just started with VB so all help is appreciated.

    Thanks, V

    savings_vba2.png

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,989

    Re: VBA call function based on change and bg-color

    Administrative Note:

    Welcome to the forum.

    Is your forum profile up-to-date and showing ONLY the oldest Excel PRODUCT that you need this to work for? Latest isn't a thing, and could in fact be one of at least three things.

    Members will tailor the solutions they offer to the Office PRODUCT (Excel, NOT Windows) that you have. Please check that your forum profile is up-to-date in this respect. If you aren't sure, in Excel go to File | Account and report what it says below the MS logo at the top of that page. If your product is for Mac, please also state this.

    The four most recent Excel products are Excel 2019, Excel 2021, Excel 2024 and MS365 - if you are using MS365, please give this name along with the version number in your profile (e.g. MS365 Version 2306). This is in the About Excel section further down the Account page.

    Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,878

    Re: VBA call function based on change and bg-color

    Formula: copy to clipboard
    =if(and(h$2>=$b3,h$2<=$c3),$e3,"")


    CF

    =LEN(H3)>0
    Attached Files Attached Files
    Last edited by JohnTopley; 11-13-2024 at 11:16 AM.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  4. #4
    Registered User
    Join Date
    11-13-2024
    Location
    Sweden
    MS-Off Ver
    MS 365 Subscription
    Posts
    6

    Re: VBA call function based on change and bg-color

    Quote Originally Posted by JohnTopley View Post
    Formula: copy to clipboard
    =if(and(h$2>=$b3,h$2<=$c3),$e3,"")


    CF

    =LEN(H3)>0
    Thank you so much, works like a charm!!

  5. #5
    Registered User
    Join Date
    11-13-2024
    Location
    Sweden
    MS-Off Ver
    MS 365 Subscription
    Posts
    6

    Re: VBA call function based on change and bg-color

    Quote Originally Posted by AliGW View Post
    Administrative Note:
    Is your forum profile up-to-date and showing ONLY the oldest Excel PRODUCT that you need this to work for? Latest isn't a thing
    Hello and thank you! You are correct, I will update my info!

+ 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. call background color change on future date
    By jafoster in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-14-2021, 09:55 PM
  2. change background textbox color based on text color in cell
    By atadaliran in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-05-2021, 05:34 AM
  3. [SOLVED] Need to change cell color based off of RGB Color being defined in 3 cells
    By Chris McGlothen in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-01-2017, 02:13 PM
  4. [SOLVED] change fill color of a range of cells based on color of a cell?
    By DarMelNel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-20-2014, 04:48 PM
  5. Change Font Color Based On Adjacent Cell Color
    By Zorro9758 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-11-2013, 02:47 PM
  6. VBA / Macro help needed to change the barchart color based on Cell Color
    By krjoshi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-28-2012, 09:15 AM
  7. [SOLVED] Function to change text color based on date?
    By Ahroo in forum Excel General
    Replies: 2
    Last Post: 08-09-2006, 10:49 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