Vba not updating formula! Beginner

dissertationhelp

New Member
Joined
Feb 9, 2015
Messages
7
Hi, I have no idea how to do a VBA, but got one online which nearly does the job. Basically i have 2000 columns for 4000 rows, so manual copy and paste will take days. I have a blank column between each which i need a basic formula inserted. EG in cell D4 i need (C5-C4)/C4. The macro i have does this but it does not update the formula for D6 where i will need (C6-C5)/C5 and so on so forth instead it copies (C5-C4)/C4 into all the blank cells i need the formulas in? Can anyone help me please?
This is the macro i am running at the moment:

Sub fcopy()
Dim r, c As Integer
For r = 4 To 55
For c = 4 To 20 Step 2
Cells(r, c).Formula = "=(c5-c4)/c4"
Next
Next
End Sub



Thanks for any replies!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Code:
cnt1 = 5
cnt2 = 4
For r = 4 To 55
For c = 4 To 20 Step 2
newrng = """=(c" & cnt1 & "-c" & cnt2 & ")/c" & cnt2 & """
Cells(r, c).Formula = newrng
cnt1 = cnt1 + 1
cnt2 = cnt2 + 1
Next c
Next r
 
Upvote 0

Forum statistics

Threads
1,216,077
Messages
6,128,685
Members
449,463
Latest member
Jojomen56

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