VBA Cell Formulas

Glasgowsmile

Active Member
Joined
Apr 14, 2018
Messages
280
Office Version
  1. 365
Platform
  1. Windows
Simple VBA I'm implementing into a spreadsheet and I have a few more columns to add but is this is the easiest or most efficient way to go about this?

VBA Code:
Sub FormulaMacro()
Worksheets("Data").Range("G10").Formula = "=((E10*100)/(100+F10)*100)/100"
Worksheets("Data").Range("G11").Formula = "=((E11*100)/(100+F11)*100)/100"
Worksheets("Data").Range("G12").Formula = "=((E12*100)/(100+F12)*100)/100"

Worksheets("Data").Range("J10").Formula = "=((H10*100)/(100+I10)*100)/100"
Worksheets("Data").Range("J11").Formula = "=((H11*100)/(100+I11)*100)/100"
Worksheets("Data").Range("J12").Formula = "=((H12*100)/(100+I12)*100)/100"
End Sub
 
Last edited:

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Assuming the formula for G12 is a typo you can do
VBA Code:
Worksheets("Data").Range("G10:G12").Formula = "=((E10*100)/(100+F10)*100)/100"
 
Upvote 0
Solution
Assuming the formula for G12 is a typo you can do
VBA Code:
Worksheets("Data").Range("G10:G12").Formula = "=((E10*100)/(100+F10)*100)/100"

The E10 and F10 will change to E11 and F11 for each cell automatically?
 
Upvote 0
Assuming the formula for G12 is a typo you can do
VBA Code:
Worksheets("Data").Range("G10:G12").Formula = "=((E10*100)/(100+F10)*100)/100"
Dang, sure enough. Also found I could do G10:G12, G14:G16 etc in a column. Can't believe I didn't know this but thank you!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,728
Members
448,987
Latest member
marion_davis

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