Macro Help

Pumper

Board Regular
Joined
Sep 12, 2013
Messages
78
Office Version
  1. 2016
Hi Everyone,

I am trying to update my macro so the data in column B (tab name “Checks”) is copied to another tab (“DATA”) into column B also. What I need is for that same data to be cut and pasted 3 times on a Monday when I run it (so it’s the same numbers for Fri/Sat/Sun) once every other day.

Any help is much appreciated

 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

mrmmickle1

Well-known Member
Joined
May 11, 2012
Messages
2,461
This could probably be a little more concise but it should get the job done.

Code:
[COLOR=#0000ff]Sub[/COLOR] CopyBasedOnDate()


    [COLOR=#0000ff]Dim[/COLOR] TodaysDate    [COLOR=#0000ff]As Integer[/COLOR]
   [COLOR=#0000ff] Dim[/COLOR] CheckLastrow  [COLOR=#0000ff]As Integer[/COLOR]
    [COLOR=#0000ff]Dim[/COLOR] DataLastRow   [COLOR=#0000ff]As Integer[/COLOR]
   [COLOR=#0000ff] Dim[/COLOR] i             [COLOR=#0000ff]As Integer[/COLOR]
    
    TodaysDate = Weekday(Date, vbMonday)[COLOR=#008000] 'Determine the Day of Week, 1 = Monday[/COLOR]
  [COLOR=#0000ff]  If [/COLOR]TodaysDate = 1 [COLOR=#0000ff]Then[/COLOR]
    
       [COLOR=#0000ff] For[/COLOR] i = 1 [COLOR=#0000ff]To[/COLOR] 3 [COLOR=#0000ff]Step[/COLOR] 1
            CheckLastrow = Sheets("Checks").Range("B" & Rows.Count).End(xlUp).Row
            Sheets("Checks").Range("B1:B" & CheckLastrow).Copy
            DataLastRow = Sheets("Data").Range("B" & Rows.Count).End(xlUp).Row
            Sheets("Data").Range("B" & DataLastRow + 1).Select
            ActiveSheet.Paste
        [COLOR=#0000ff] Next [/COLOR]i
    
[COLOR=#0000ff]           Else
[/COLOR]  
        CheckLastrow = Sheets("Checks").Range("B" & Rows.Count).End(xlUp).Row
        Range("B1:B" & CheckLastrow).Copy
        DataLastRow = Sheets("Data").Range("B" & Rows.Count).End(xlUp).Row
        Sheets("Data").Range("B" & DataLastRow + 1).Select
        ActiveSheet.Paste


[COLOR=#0000ff]    End If[/COLOR]

[COLOR=#0000ff]End Sub[/COLOR]
 

Pumper

Board Regular
Joined
Sep 12, 2013
Messages
78
Office Version
  1. 2016
Thanks for your help mrmmickle1

That is enough for me to work with, appreciate your time and effort

 

mrmmickle1

Well-known Member
Joined
May 11, 2012
Messages
2,461
Glad to help. Let me know if you have any additional questions or need adjustments.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,627
Messages
5,838,445
Members
430,549
Latest member
jayjay2022

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
Top