+ Reply to Thread
Results 1 to 7 of 7

intersect question

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

    intersect question

    I've made a calendar With a lot of other things on it.

    Now i made for every month a range that contains only the weekdays.
    And check if the user selection is different of the weekdayrang . When he is bigger i say selection contanins a weekend day.

    A friend told me that it was posible to dedect with intersect that the user selection contains weekend day's. But i don't know how ?

    Must i change the range of the moth include with the weekenddayS ?
    Thangs for the help so far
    Attached Files Attached Files
    Last edited by glda19; 03-07-2018 at 02:47 PM.

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: intersect question

    If your month of weekdays is on row 5 from column 1 to column 21 then using VBA
    Please Login or Register  to view this content.
    But your layout has the days on multiple row with different beginning and ending columns so the Intersect function could not be applied to an entire month of weekdays. If you had blocks of data where the beginning cell was in the same column as the following weeks and the ending cell was in the same column as the preceeding weeks, like a 4 row by five column matrix and all were weekdays, then you could use the Intersect function on the entire block like
    Please Login or Register  to view this content.
    The Intersect function does just that, it returns true if the target cell or cells intersect the parameters in the arguments.
    Last edited by JLGWhiz; 03-07-2018 at 04:58 PM.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

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

    Re: intersect question

    It is not about the activecell but off a selection of cells

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

    Re: intersect question

    what did you mean with not the same begin and end cell

  5. #5
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: intersect question

    I thought the 5 by 4 matrix would explain what I I meant. If you want to use Intersect function to find if a user selects a cell within your calendar weekdays, you have to be able to define a range that includes only those days. So when your month begins in Column D and Ends in column F, there is not a equilateral matrix, So, although you could define a rang to cover all the days, it would have to include cells that precede the first of the month and cells that follow the last of the month. So it leaves the Intersect function subject to fictitious returns. If you can imaginge drawing a vertical line through a rows of data in a range on your sheet, every time the line passes through a row it is an intersect with that row, If your line is more than one column wide, then there will be a multiple cell intersect for each row the line crosses. I only used the active cell as an example of how to return whether there is an intersect or not. The function is a powerful VBA function and can be used in other ways. It can be used to return values, define a range of cells out of a larger range of cells and more. You can do a web search for a tutorial on using the VBA intersect function if you want more details.

    but, again, I don't see a practical way to use it on your calendar layout. Maybe someone else can.
    Last edited by JLGWhiz; 03-07-2018 at 06:46 PM.

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

    Re: intersect question

    when i use the range b5:h10 and the user make a selection how can check if it's contain weekend days.

  7. #7
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: intersect question

    on your calendar, columns G:H and P:Q are not weekdays, which means that B:F and K:O are weekdays, but might include holidays. Nonetheless, you can use the intersect method like this
    Please Login or Register  to view this content.
    The problem is that if the user has selected a cell in those ranges that is not on one of your calendar pages, it will still indicate a weekday. You have a lot of gaps on the sheet between months. You can use the narrower range of B5:F10, but it would still leave 2 cells subject to invalid return. If you want to go to the trouble of locking all cells except the calendar days, then you could use the code above with a high degree of confidence, because the user would be blocked from selecting anything except a calendar day.
    Last edited by JLGWhiz; 03-09-2018 at 01:48 PM.

+ 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. Need to add 0 where Value X and Value Y intersect
    By cmtgrame in forum Excel General
    Replies: 3
    Last Post: 05-14-2014, 12:57 PM
  2. Can I add another Else to this intersect?
    By lastat in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-17-2010, 04:41 PM
  3. If Intersect
    By astanix in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-02-2010, 05:56 PM
  4. Difference between Intersect and Not Intersect is Nothing
    By batman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-13-2009, 05:39 PM
  5. Intersect in VBA
    By mattydalton in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-30-2009, 08:15 AM
  6. [SOLVED] Intersect
    By Arne Hegefors in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-25-2006, 04:40 AM
  7. Intersect
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-19-2006, 05:45 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