How to loop a calculation & If statement

sam71

New Member
Joined
May 1, 2011
Messages
14
Hi all,

I have been struggling to find an answer for the code on a simple calulation.

I recorded a macro on one cell and got this code but need it to relate to all rows until the data stops!
Basically column H is muliplied by 1.15 to get an answer in column I

Code:
Range("I2").Select
    ActiveCell.FormulaR1C1 = "=RC[-1]*1.15"

I also need to run an if statement against a column so I can get an idea if a product is in stock or out of stock!

I manually use =IF(AB2>0, "0", "1")
 
Last edited:

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Try

Code:
LR = Range("H" & Rows.Count).End(xlUp).Row
Range("I2:I" & LR).FormulaR1C1 = "=RC[-1]*1.15"
 
Upvote 0
Try like this: change AC to the correct column

Rich (BB code):
Range("AC2:AC" & LR).Formula = "=IF(AB2>0,0,1)"
 
Upvote 0
How would I go about having Column N = somthing if Column D was a certain thing

The reason I need this is that I will be importing product data from multiple supplers however I want to keep set Category structure!

For example column D (Category Code) is "16A" so I want column N (Category) to be "Network|Cables|"

Is there a way to have this in one pice of code or would I need a new code for every different entry in column D? Column D has upto 50 different codes!
 
Upvote 0
Thanks for that! I actually thought of something similar might need to be done! Had a look at the link and most of it went straight over my head (just woke up though)
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,763
Members
452,940
Latest member
rootytrip

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