Need a macro

Mldeuser

Well-known Member
Joined
Dec 27, 2008
Messages
573
Office Version
  1. 365
Platform
  1. Windows
I have a spread sheet that is broken into two sections, the first section requires some input in certain columns then the other columns have formauls that work off the information keyed into the first five columns.

The second part of the spread sheet is all hand entered.

There is a blank row that seperates the two sections.

I need a macro that will look at column "C" starting a row "12" and if the cell is populated to insert a formula into column "I" until it comes to the blank row then it should stop as the second half of the spread sheet is hand entered and no formulas are needed.

Thanks
Mark
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Hello,

you haven't specified the formula, so I made one up, you will need to change it.

Code:
Sub ADD_FORMULA_TO_I()
    For MY_ROWS = 12 To Range("A" & Rows.Count).End(xlUp).End(xlUp).Row - 1
        If Not IsEmpty(Range("C" & MY_ROWS).Value) Then
            Range("I" & MY_ROWS).Formula = "=G" & MY_ROWS & "+H" & MY_ROWS
        End If
    Next MY_ROWS
End Sub

this assumes col A always contains data.
 
Upvote 0
Here is the formula that I will be inserting into the macro:

IF(OR(D13="IP",U13="C"),(E13*H13)+(S13),IF(AND(D13="n/a",(S13>0)),S13,IF(G13>$B$3,"n/a",IF(OR(YEAR(D13)<(YEAR($B$3)),(MONTH(D13)<MONTH($B$3))),(E13/(G13-F13+1))*($B$3-G13)+(E13*Q13)+(S13),IF(AND(DAY(D13)<=20,MONTH(D13)=MONTH($B$3)),(E13/(G13-F13+1))*($B$3-G13)+(E13*Q13)+(S13),IF(AND(DAY(D13)>20,MONTH(D13)=MONTH($B$3)),(E13/(G13-F13+1))*(($B$3-F13)+1)+(E13*Q13)+(S13)))))))

I will give your macro a run

Thanks
Mark
 
Upvote 0
I tested the Macro and the only problem is that it does not stop at the break between sections. Is there a way for the macro to stop when it reaches the blank row.
 
Upvote 0
I made a few changes to the macro and it does what I need.

Thank you for your help with this

Mark
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,020
Members
448,938
Latest member
Aaliya13

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