What is wrong with my formula code

floridagunner

Board Regular
Joined
Jul 20, 2007
Messages
60
Hello all,

I'm using the following code to enter a formula into column B which references values in column T:


Code:
'Populate Program name column with formulas now referencing values in column-T.

Dim ab As Long, c As Long
ab = Cells(Rows.Count, "T").End(xlUp).Row
For c = 2 To ab
Range("B" & c).Formula = "=IF(LEFT(T" & c & ",1)=""D"",IF(VALUE(MID(T" & c & ",6,2)) " & _
"<24,""Carbon Abatement"",""EE Reloaded""),""EEE"")"
Next c

The problem is that when Excel gets to processing this section of the code it is taking it approximately 35 minutes to process for about 42,000 rows, which I think is abnormally long.

I want to know if there is a way I can speed this process up. Is there a data type declaration that I should be using? Is long perhaps the wrong data type to be using? Should I be using a different type of code alltogether?

Any help is appreciated.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Try putting the formula in all cells at the same time instead of looping..

Code:
ab = Cells(Rows.Count, "T").End(xlUp).Row
Range("B2:B" & ab).Formula = "=IF(LEFT(T2,1)=""D"",IF(VALUE(MID(T2,6,2)) " & _
"<24,""Carbon Abatement"",""EE Reloaded""),""EEE"")"
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,020
Members
448,939
Latest member
Leon Leenders

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