Excel/Copying a formula in dynamic row range
your last solution worked like a charm. I have another question in the same project.
This time I want to put a below formula in C6
Formula = =C5/C4
Formula = Production Plan (Units) - Revised/Run Rate (Units/Hour) - Current
And want to copy this formula in C5,D5 etc..whereever B column contains a word "Production Plan (Hrs) - Revised".
Basically I want to calculate like this -
Production Plan (Hrs) - Revised = Production Plan (Units) - Revised / Run Rate (Units/Hour) - Current
And want to apply it in whole sheet. (dynamic data)
Please let me know if you have any question.
Use the below code
Dim r As Range, c As Range
For Each c In Range("B2:B" & Cells(Rows.Count, "B").End(xlUp).Row)
If c.Value = "Production Plan (Hrs) - Revised" Then
For Each r In Range("C" & c.Row & ":" & Cells(c.Row, Columns.Count).End(xlToLeft).Address)
r.Formula = "=" & r.Offset(-1, 0).Address(False, False) & "/" & r.Offset(-2, 0).Address(False, False)
Hope that helps!
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here