Selection of Cells

bschulze

Active Member
Joined
Jun 2, 2005
Messages
289
I am creating a macro to do some calculations on one of my sheets. I want to write the macro to insert these calculations however do not want the macro to select the cell...just for simplification purposes. my code is:

Range("B3").Select
ActiveCell.FormulaR1C1 = "=IF(SUM(AL!C[5])<>0,SUM(AL!C[5]),""No Data Found"")"


I want to get rid of the "Range("B3").Select"



Any help would be greatly appreciated.
 

Some videos you may like

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

bschulze

Active Member
Joined
Jun 2, 2005
Messages
289
there are about 50 formulas in this macro. How would it know what cell to insert the formula in?
 

kjo1080

Active Member
Joined
Aug 2, 2004
Messages
325
you would have to tell it by leaving Range("B3").Select and changing that cell for each formula.

We are going in circles here. Maybe I don't understand what you are trying to do.
 

bschulze

Active Member
Joined
Jun 2, 2005
Messages
289

ADVERTISEMENT

Sorry I am not being more specific. The code is very busy and I was trying to simplify it. Here is an example:

Range("B4").Select
ActiveCell.FormulaR1C1 = "=IF(SUM(AK!C[5])<>0,SUM(AK!C[5]),""No Data Found"")"
Range("B5").Select
ActiveCell.FormulaR1C1 = "=IF(SUM(AZ!C[5])<>0,SUM(AZ!C[5]),""No Data Found"")"
Range("B6").Select
ActiveCell.FormulaR1C1 = "=IF(SUM(AR!C[5])<>0,SUM(AR!C[5]),""No Data Found"")"
Range("B7").Select
ActiveCell.FormulaR1C1 = "=IF(SUM(CA!C[5])<>0,SUM(CA!C[5]),""No Data Found"")"
Range("B8").Select
ActiveCell.FormulaR1C1 = "=IF(SUM(CO!C[5])<>0,SUM(CO!C[5]),""No Data Found"")"
Range("B9").Select
ActiveCell.FormulaR1C1 = "=IF(SUM(CT!C[5])<>0,SUM(CT!C[5]),""No Data Found"")"
Range("B10").Select
ActiveCell.FormulaR1C1 = "=IF(SUM(AL!C[5])<>0,SUM(AL!C[5]),""No Data Found"")"



I am trying to get it to look like:


Range("B9").select = "=IF(SUM(AL!C[5])<>0,SUM(AL!C[5]),""No Data Found"")"
Range("B9").select = "=IF(SUM(AL!C[5])<>0,SUM(AL!C[5]),""No Data Found"")"
Range("B9").select = "=IF(SUM(AL!C[5])<>0,SUM(AL!C[5]),""No Data Found"")"
Range("B9").select = "=IF(SUM(AL!C[5])<>0,SUM(AL!C[5]),""No Data Found"")"
Range("B9").select = "=IF(SUM(AL!C[5])<>0,SUM(AL!C[5]),""No Data Found"")"
Range("B9").select = "=IF(SUM(AL!C[5])<>0,SUM(AL!C[5]),""No Data Found"")"
Range("B9").select = "=IF(SUM(AL!C[5])<>0,SUM(AL!C[5]),""No Data Found"")"
 

just_jon

Legend
Joined
Sep 3, 2002
Messages
10,473
Change these

Range("B4").Select
ActiveCell.FormulaR1C1 = "=IF(SUM(AK!C[5])<>0,SUM(AK!C[5]),""No Data Found"")"


to these

Range("B4").FormulaR1C1 = "=IF(SUM(AK!C[5])<>0,SUM(AK!C[5]),""No Data Found"")"

No need for Selects.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,312
Messages
5,595,430
Members
413,990
Latest member
Kher83

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
Top