+ Reply to Thread
Results 1 to 11 of 11

vba insert X in case of Saturday or Sunday

  1. #1
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    vba insert X in case of Saturday or Sunday

    Hello,
    in the attached workbook it is possible to insert a letter X in the range C10:AG10
    in case of Saturday (sab-sabato) or Sunday (dom-domenica) in range C8:AG8.
    it must be a macro because sometimes the letter X must be entered manually
    max
    Attached Files Attached Files

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: vba insert X in case of Saturday or Sunday

    Hi max_max,

    How about this?

    Please Login or Register  to view this content.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Try this !


    As a beginner starter :

    PHP Code: 
    Sub Demo()
        [
    C10:AG10].Formula "=IF(WEEKDAY(C8,2)=6,""X"","""")"
        
    [C10:AG10].Formula = [C10:AG10].Value2
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  4. #4
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: vba insert X in case of Saturday or Sunday

    Hi arkadi your macro work well.
    I have modified with selectionchange:
    Please Login or Register  to view this content.
    but non work this:

    Dim ws As Worksheet

    Range("C10:AG10").Select
    Selection.ClearContents


    Set ws = ThisWorkbook.Worksheets("CONF")

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: vba insert X in case of Saturday or Sunday


    Remove any Select & Selection, just directly work on objects !

    Copy my code to the Foglio3(CONF) worksheet module and see how it works !
    Update formula with >5 instead of =6, at bambino level ‼
    Last edited by Marc L; 06-06-2019 at 02:28 PM.

  6. #6
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: vba insert X in case of Saturday or Sunday

    hi arkadi:
    I can't add other X letters besides the macro ones
    Please Login or Register  to view this content.
    ------------------------------------------------------------------------------------------------------------------------

    hi marcL:
    I can't add other X letters besides the macro ones

    Please Login or Register  to view this content.
    max

  7. #7
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: vba insert X in case of Saturday or Sunday

    My code (even converted to selection change), would not stop manual "X", but you are adding a line that removes ALL "X":
    Please Login or Register  to view this content.
    Maybe you need code that when your cell C3 (I think it was C3?) changes dates, then you clear that range, but not on "selection change" since that means every time you select any cell, all X's are removed and then only Sat/Sun will have X again.

  8. #8
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: vba insert X in case of Saturday or Sunday

    At every change of month, the X of Saturdays and Sundays must change
    but having a chance to add other X manuals (monthly holidays)

  9. #9
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: vba insert X in case of Saturday or Sunday

    Hi arkadi and marcL I removed selectionchange and left the macros

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    They work well
    max

  10. #10
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED.

    Also,you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner
    of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.
    Last edited by Marc L; 06-06-2019 at 05:35 PM.

  11. #11
    Forum Contributor max_max's Avatar
    Join Date
    06-28-2013
    Location
    italy - venice
    MS-Off Ver
    Excel 2007
    Posts
    1,693

    Re: vba insert X in case of Saturday or Sunday

    Hi marcL and arkadi I waited this morning to try the macros in the office and both work.
    Thanks again to everyone.
    max

+ 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. How to ignore saturday/sunday on formulas
    By fzoull in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-22-2016, 09:47 AM
  2. [SOLVED] Every Saturday and 2nd Sunday of each month
    By Titan27 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-20-2016, 09:56 PM
  3. first day of the month is saturday, sunday or else ?
    By Ramo13541 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-27-2016, 07:16 PM
  4. [SOLVED] If Saturday, +2. If Sunday, +3
    By DavidRoger in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-16-2015, 04:11 AM
  5. Locate Saturday and Sunday
    By boldcode in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-10-2015, 01:33 PM
  6. Saturday, Sunday or Holiday BY-PASS
    By GPErtel in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-19-2013, 08:26 PM
  7. identifying saturday and sunday in a date
    By mdub72 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-15-2008, 04:23 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