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 create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

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,118,726
Messages
5,573,837
Members
412,552
Latest member
sfay
Top