+ Reply to Thread
Results 1 to 11 of 11

auto border every 4 week on the right

  1. #1
    Forum Contributor
    Join Date
    12-25-2012
    Location
    gent,belgium
    MS-Off Ver
    Excel 2021
    Posts
    146

    auto border every 4 week on the right

    hi
    I have made a calandar and every 4 weeks i need a red tick line on the right of the cels.

    So for 2017 the first line is on the weeknumber 3 than 7 than 11 and the last line for 2017 is in week 51
    But when i change the year the lines must auto change
    so for 2018 it must be week 3 7 11 15 and so on
    Attached Files Attached Files

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: auto border every 4 week on the right

    I had to do some checking since I noticed that some week numbers were repeated.

    Other than that I recorded a macro so I could get the syntax for a red border, and then used the MOD operator to determine if it was a 4th week.
    Attached Files Attached Files
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Forum Contributor
    Join Date
    12-25-2012
    Location
    gent,belgium
    MS-Off Ver
    Excel 2021
    Posts
    146

    Re: auto border every 4 week on the right

    but how did you actived the macro

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: auto border every 4 week on the right

    Go to the View ribbon and select Macro and you can select it from there. You can also use Options to assign a shortcut key such as CTRL-w or CTRL-q (those two CTRL keys are used to start and stop scrolling so remapping them won't do much damage).

  5. #5
    Forum Contributor
    Join Date
    12-25-2012
    Location
    gent,belgium
    MS-Off Ver
    Excel 2021
    Posts
    146

    Re: auto border every 4 week on the right

    but i your example file when i pres on the up down button it change the lines So how do you make that the macro is started

  6. #6
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: auto border every 4 week on the right

    When you get to view the macro, you can either run it or if you click on Options, you can assign it to a CTRL key.
    Attached Images Attached Images

  7. #7
    Forum Contributor
    Join Date
    12-25-2012
    Location
    gent,belgium
    MS-Off Ver
    Excel 2021
    Posts
    146

    Re: auto border every 4 week on the right

    i think you don't under stand me
    When i download your example and when i pres the up down buttun the macro automaticly runs . How did you do that

  8. #8
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: auto border every 4 week on the right

    It sounds like we are literally not on the same page. What up and down button are you talking about?

  9. #9
    Forum Contributor
    Join Date
    12-25-2012
    Location
    gent,belgium
    MS-Off Ver
    Excel 2021
    Posts
    146

    Re: auto border every 4 week on the right

    tel me how you start your macro in your example.
    The up down button is on the sheet kalender on the top left

  10. #10
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: auto border every 4 week on the right

    I hadn't noticed that thing before. It's called a spinner and it can change the years between 1990 and 2200 in increments of 1.

    It does not run the macro for me. I think what you are seeing is a mistake on my part - there is a weakness in the macro I created. It does not clear the formatting when the year is changed. That might be OK for a couple of years since the weeks within the years might not change. Eventually, you may come across a year where the weeks don't line up the way they do now. Then you may get "double" red lines.

    Here's what I can do: I can write a routine to restore the default formatting and run it as the first step in the macro that does the lines. Then I can use a change event so when you change the year, it will fire the macro automatically.

    However, we have another problem. The reason we are putting a red line behind week 3 of 2017 is that Sunday is actually week 52 of the previous year. If Monday is the first of the year, then we would have to put the first red line behind week 4. I can adjust the code to look at cell B3. If it's 52, I will do one thing. If it's 1, I will do another.

    At the moment, I am running the macro using View -> Macro -> Run. As I mentioned above, in the next version, I will tie it to the cell affected by the spinner.

    I have this all mapped out in my mind, but it will take me a day or two to program it.

  11. #11
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: auto border every 4 week on the right

    I can probably program this, but I can't test it. What happens when I change the year from 2017 to anything else, I get #VALUE errors all over the place. When I change it back, the errors don't go away. There is some sort of defect in the logic that is generating the dates.

    If this is your program, can you fix this error?

+ 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. Remove border from legend entry without removing border from pie chart
    By cartman88 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 08-06-2015, 04:16 AM
  2. [SOLVED] Need help auto-updating a formula for week over week change
    By yanger87 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-14-2015, 12:45 PM
  3. [SOLVED] Generate Auto week no.
    By joh46k in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 04-25-2013, 11:20 PM
  4. Replies: 1
    Last Post: 03-29-2011, 08:22 AM
  5. create border across entire row based on current week
    By sentofuno in forum Excel General
    Replies: 8
    Last Post: 01-22-2008, 09:03 AM
  6. Replies: 1
    Last Post: 08-11-2005, 09:05 PM
  7. Auto-update when the week changes
    By jzullo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-10-2005, 08:07 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