Apply formula in a cell if a condition is met

lifesgood

New Member
Joined
Feb 22, 2018
Messages
5
Hi,

I need a macro that will apply the below mentioned formula in column J if the value of a cell in column C is "Hits_US" and the value of a cell in column D is "harry". Below is the formula

=((Column G*32)+(Column H*28)+300)/60
Please note that there will be other values in column J. So, only if the condition is met, the formula has to be applied.
I tried to do this in parts. I first tried to multiply the value in column G by 32. But it did not work.
For i = 1 To 10 If Sheets(1).Range("C" & i).Value = "Hits_US" And Range("D" & i).Value <> "harry" Then Cells(i, 10) = Cells(i, 7) * 32 End If Next i
Can anyone help me with this? Any help would be greatly appreciated! Thanks!
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hi,

I don't see why this wouldn't work :

Code:
[FONT=Arial][COLOR=#242729]For i = 1 To 10 

If Range("C" & i).Value = "Hits_US" And Range("D" & i).Value <> "harry" Then
 Range("J" & i).Value = (((Range("G" & i).Value * 32) + (Range("H" & i).Value * 28))+300)/60
 End If

 Next i[/COLOR][/FONT]
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,500
Members
449,090
Latest member
RandomExceller01

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