You are here:

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.!144&authkey=!AMmQq1D4vCEcXEo


Hi Prabhat,

Use the below code

Sub ApplyFormula()
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)
       Next r
   End If
Next c

End Sub

Hope that helps!


About Excel
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


All Answers

Answers by Expert:

Ask Experts




[Overview] Having hands-on experience with Excel, I can able to answer questions which is related to Conditional Formatting, Goal Seek, Scenarios, Subtotal, Validation, Pivot Table, Shared Workbook, Excel Sheet / Workbook Protection, Excel Settings, Excel Shortcuts and the Two Major & Massive Key Areas of Excel (i.e.) Worksheet Functions and Excel VBA (Macro).

[Services] Volunteer in many of the Excel Discussion Groups / Forums and answered more than 10,000+ questions (approx.)

[Client FAQs] My Solution Files

[Not Interested In] Chart Questions

[Something Controversial]
*50% of answers never been read by the questioner's.
*Only 5% of questioner's provide feedback about the suggested answers.


Vast Experience

Ms-Office, Oracle, Foxpro, C, COBOL etc.,

©2016 All rights reserved.