# How to get a value in a cell n times

Closed
Abhay - Jan 20, 2011 at 01:18 AM
Abhay - Jan 20, 2011 at 05:05 AM
Hello,

I have an issue in creating a data sheet. I read all the forums but unable to find the solution. I want a macro/ formula leting my job get done.

Here is an example:

Salary 1000
Months 4
Increment 50

To make it simple- every month salary is 1000 bucks initially which is increasing at the rate of 50 bucks every 4 months

If this is the data then I want it to be arranged like this in different location within the same sheet:

1 1000
2 1000
3 1000
4 1000
5 1050
6 1050
7 1050
8 1050
9 1100
10 1100
11 1100
12 1100
13 1150...... and so on may be till 60 months.

I hope I clarified my concern. Please do revert with the solution.

venkat1926 Posts 1864 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 810
Jan 20, 2011 at 04:38 AM
suppose your data is like this from A1 to C2

Salary Months Increment
1000 4 50

try this macro

```Sub test()
Dim r As Range, mo As Integer, inc As Long, m As Integer
Dim dest As Range
Set r = Range("A2")
mo = Range("B2").Value
inc = Range("c2").Value
Set dest = Range("A10")
Range(dest, dest.Offset(mo - 1, 0)).Cells.Value = r.Value
m = 2
Do
If m > 15 Then Exit Do
Set dest = dest.End(xlDown).Offset(1, 0)
Range(dest, dest.Offset(mo - 1, 0)).Cells.Value = r.Value + (m - 1) * inc
m = m + 1
Loop
End Sub```
Thanks a ton... its working :-)

Could you manage to provide some manual to learn VB?