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.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
there are about 50 formulas in this macro. How would it know what cell to insert the formula in?
 
Upvote 0
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.
 
Upvote 0
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"")"
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,930
Members
449,094
Latest member
teemeren

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