VBA Fill number sequence & sum formula in step-3

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,362
Office Version
  1. 2010
Hello,

1- I want fill number 1 in M8, and every step-3 add 3 in it, so M11=4, and so on...
2- I want sum P8+O9+N10 and sum place in M10, do this sum also every step-3
3- do all as long as data are find in column B

Here is the example


Book1
ABCDEFGHIJKLMNOPQ
1
2
3
4
5
6
7
811824
92473
10313257
1144752
125329
1368473
1477932
158356
1699266
171010653
1811347
191212554
201313770
2114527
22154257
231616941
2417266
251810347
261919842
2720347
28219365
292222590
3023428
31247536
322525554
3326365
342716635
352828932
3629473
373010149
383131653
3932653
403310248
413434851
4235536
43365167
443737914
4538338
463992102
4740401022
48266
4910266
50
51
52
53
Sheet2
Cell Formulas
RangeFormula
M10=SUM(P8,O9,N10)
M13=SUM(P11,O12,N13)


Thank you all
Excel 2000
Regards,
Moti
 
Last edited:

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi I am new to VBA but I try to help you, so please write me back if it helped you, I do your exercises one by one :)

First try: (replace 30 with the last row you need)


Sub fill()
Dim i As Integer


For i = 8 To 30 Step 3


Cells(i, "m").Value = i - 7


Next




End Sub
 
Upvote 0
2. part:

Sub szumd()



Dim i As Integer


For i = 10 To 30 Step 3


Cells(i, "m").Value = Cells(i - 2, "p") + Cells(i - 1, "o") + Cells(i, "n")


Next




End Sub
 
Upvote 0
3. You can modify the other code too, just adopt these minor changes. Hope that it helped, please write back beacuse I always asked for help and I am learning since 2 weeks VBA :D

Sub fill()Dim i As Integer
Dim row As Long


row = Cells(Rows.Count, 2).End(xlUp).row


For i = 8 To row Step 3


Cells(i, "m").Value = i - 7


Next




End Sub
 
Upvote 0
3. You can modify the other code too, just adopt these minor changes. Hope that it helped, please write back beacuse I always asked for help and I am learning since 2 weeks VBA :D

Sub fill()Dim i As Integer
Dim row As Long


row = Cells(Rows.Count, 2).End(xlUp).row


For i = 8 To row Step 3


Cells(i, "m").Value = i - 7


Next




End Sub
makiwara, your code is working Perfect!! Getting a desire result as request.

Below is a modified code of Post#2, as you suggest it is also working fine
Code:
 Sub szumd()
 Dim i As Integer
 Dim row As Long
 row = Cells(Rows.Count, 2).End(xlUp).row + 2
 For i = 10 To row Step 3
 Cells(i, "m").Value = Cells(i - 2, "p") + Cells(i - 1, "o") + Cells(i, "n")
 Next
 End Sub

Thank you for your kind help

Have a nice day

Good Luck

Kind Regards,
Moti :)
 
Upvote 0

Forum statistics

Threads
1,214,789
Messages
6,121,593
Members
449,038
Latest member
Arbind kumar

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