Copy paste based on current month

austin350s10

Active Member
Joined
Jul 30, 2010
Messages
321
Is there a way to copy a range of cells based on the current month?

Something like this maybe:
Code:
if systemMonth=12 then
      Range("A1:D12").Select
      Selection.Copy
      Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _:=False, Transpose:=False

else systemMonth=11 then
      Range("A1:D11").Select
      Selection.Copy
      Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _:=False, Transpose:=False

'so on.....through the months of the year

end if
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
How would I modify this so if the system month = 12 it copy/pastes a certain range but if the system month = 11 it copy/pastes a different range?

EXAMPLE:

if system month=12, then copy/paste range = "A1:D12"
if system month=11, then copy/paste range = "A1:D11"
if system month=10, then copy/paste range = "A1:D10"
if system month=9, then copy/paste range = "A1:D9"
if system month=8, then copy/paste range = "A1:D8"
if system month=7, then copy/paste range = "A1:D7"
if system month=6, then copy/paste range = "A1:D6"
if system month=5, then copy/paste range = "A1:D5"
if system month=4, then copy/paste range = "A1:D4"
if system month=3, then copy/paste range = "A1:D3"
if system month=2, then copy/paste range = "A1:D2"
if system month=1, then copy/paste range = "A1:D1"

I was thinking a giant if then statement but Im not too sure :-\

Thank You For Your Help
 
Upvote 0
No need for If

Code:
Sub atest()
With Range("A1:D" & Month(Date))
    .Copy
    .PasteSpecial Paste:=xlPasteValues
End With
End Sub
 
Upvote 0
Cool that works really good. My bad though. I was taking a closer look at the application I plan on using this script in and the range order is a bit different. Can't seem to adjust your code to fit.

Should be:

if system month=12, then copy/paste A1:L12
if system month=11, then copy/paste A1:K12
if system month=10, then copy/paste A1:J12
if system month=9, then copy/paste A1:I12
.......

Any ideas?

Sorry....
 
Upvote 0
Try

Code:
Sub atest()
With Range(Cells(1, 1), Cells(12, Month(Date)))
    .Copy
    .PasteSpecial Paste:=xlPasteValues
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,399
Latest member
alchavar

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