VBA Copy Paste if criteria is met

Fleiding

New Member
Joined
Aug 27, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I'm creating a daily revenue report which displays the revenue of that day, month to date statistics, and a few things more. I have 31 different sheets, corresponding to each day of the month. A few details need to be manually entered in the sheet called "START", which a macro copies to a few separate sheets and clearing the entered details after clicking a button. I now manually export the corresponding sheet to PDF each day, but I created a sheet called "DAILY" where I want to paste the values from each day corresponding to the date entered in "START".

I have the following macro working which will achieve this:
VBA Code:
Option Explicit

Sub Copy_Paste_Day_To_Daily()
'Copy paste the corresponding day of date in START to DAILY.

    With Sheets("START")
        If .AutoFilterMode Then .AutoFilterMode = False
            With .Range("A9:A9")
            .AutoFilter 1, 1 / 8 / 2020
    End With
    
    Sheets("01").Range("A1:K113").Copy
    Sheets("DAILY").Range("A1:K113").PasteSpecial xlPasteValues
      .AutoFilterMode = False
   End With
   
End Sub
I'm not sure how to edit - or improve - this macro that if not the first day of the month is selected but the second day, it will copy paste data from sheet "02" (and continuing to the last day of the month). I assume there must be a better way instead of using dd/mm/yyyy, because September is already around the corner and it would be time consuming to update this every month.

Can someone steer me in the right direction? Hopefully I clearly explained myself. If not, please let me know! :)
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Hello,

VBA Code:
Sub day_sheet()
    For MY_SHEETS = 1 To 31
        Sheets(Format(MY_SHEETS, "00")).Select
        'your code here
    Next MY_SHEETS
End Sub

does this work as expected?
 
Upvote 0

Forum statistics

Threads
1,215,432
Messages
6,124,858
Members
449,194
Latest member
HellScout

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top