Copy number down cell using VBA

akima

New Member
Joined
Mar 4, 2016
Messages
8
Hi Wizards,

Can you help. I need the value of A6 to be copied down in the active cell 7 times up to number 52 then start again at 1 up to 52 using <acronym title="visual basic for applications" style="border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: rgb(0, 0, 0); cursor: help; color: rgb(51, 51, 51); background-color: rgb(250, 250, 250);">VBA</acronym> e.g.

If A6 =5 and active cell is C20

C20 = 5
C21 = 5
C22 = 5
C23 = 5
C24 = 5
C25 = 5
C26 = 5
C27 = 6
C28 = 6
C29 = 6
C30 = 6
C31 = 6
C32 = 6
C33 = 6
C34 = 7
C35 = 7
C36 = 7
C37 = 7

etc up to 52 and start again at 1 up to 52.

This will need to happen whether I start from C20 or C31.

Thanks so much for your help.
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Try this:
Code:
Sub Active_Cell_Down()
Dim i As Long
Dim Lastrow As Long
Dim ans As Integer
ans = 52 - Cells(6, 1).Value + 1
Lastrow = ActiveCell.Row
    
    For i = 1 To ans
        Cells(Lastrow, ActiveCell.Column).Resize(7, 1).Value = Cells(6, 1).Value + i - 1
        Lastrow = Cells(Rows.Count, ActiveCell.Column).End(xlUp).Row + 1
    Next

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,824
Members
449,050
Latest member
Bradel

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