Posts by cdug

Important Notice


Please note that on 14th December 2023 users will experience an expected outage whilst we make upgrades to our network. We anticipate this process may take a couple of hours and so we apologise in advance for any inconvenience.




    So this code doesn't work. I recorded a macro and then changed it to be applied to all worksheets in the workbook. It doesn't like ".Apply" but when I take it out, there is no error message, but it does not sort the data.

    I have the following code which works perfectly until I want not just today's date, but the past 5 days as well




    I've tried

    Code
    If wsheet.Range("A" & x) = Date or Date - 1 or Date - 2 or Date - 3 or Date - 4 or Day - 5 Then


    however, this copies every date, even if they are way older than the previous 5 days days. How do I modify so that it will copy and paste all dates that are within the past 5 days from today?

    Re: VBA to copy and paste certain cells if cell contains today's date or the past 5 d


    I got this, but I can't figure out how to apply that to every sheet. Also, how would I delete duplicates on the Updates page so that when the macro runs, it won't keep pasting the same thing.




    Edit: I figured how to remove duplicates with

    Code
    Sub DeleteDuplicates()
        
        Range("A1:G5000").RemoveDuplicates Columns:=Array(6), Header:=xlYes
        
    End Sub



    However, I still can't figure out to run the first code through every page. Also, my code only checks to see if it is equal to today's date, how do I get it to check the past 5 days as well? In addition, by copying and pasting, it takes a lot of time, how do I speed this process up?

    So I will try to be as specific and clear as possible. I am trying to pull today's date from multiple different workbooks and multiple different sheets. There is a total of 14 workbooks and 980 worksheets and opening and closing the workbooks is not going to work as I have already tried this and it takes way too long (very slow shared network). I need one workbook to pull today's date from all 980 sheets (if it is even there) and display what workbook and worksheet it is coming from. Thank you very much!

    Re: Copy every 18 cells in a column (A) and paste in multiple columns (C __>




    Is this what you are looking for?

    Re: Copy every 18 cells in a column (A) and paste in multiple columns (C __>


    I Just realized I misread your post. So this isn't correct, but let me try to fix it.






    Try this:

    Re: Stop Application.Ontime to stop running upon closing so that it won't open back u


    Thanks for the response! So this stops the timer when I run the macro. However, when I close the file, it will open back again if I have another file open too. This makes me wonder if it is stopping it or not when the file is closing. Could it be something wrong with

    Code
    Private Sub Workbook_BeforeClose(Cancel As Boolean) 
        Call StopRefresh 
    End Sub
    Code
    Sub Refresh()   'This automatically refreshes the time every 10 seconds
        Application.OnTime Now + TimeValue("00:00:10"), "refresh"
        Application.Calculate
    End Sub
    Sub StopRefresh()
    Application.OnTime Now + TimeValue("00:00:10"), "refresh", False
    End Sub



    Code
    Private Sub Workbook_Open()
        Call Refresh
    End Sub
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
        Call StopRefresh
    End Sub


    I'm not sure why the stop refresh isn't working. Should I use something different? The refresh is essentially just calculating every 10 seconds and I need this to stop when the workbook closes. Thank you.