Static Cell References

3rRiXzN0O

New Member
Joined
May 5, 2011
Messages
8
Is there a way to delete rows with VBA without changing my cell references?


I’m doing a web query that I will refresh daily. For example, every time I pull data it populates column A for 20 rows. I then delete the first 10 rows. I then want to take the average of the remaining 10 rows. If I have the formula =AVERAGE(Sheet1!A1:A10) in a cell on Sheet2 then every time VBA deletes rows 1-10 the formula returns a #REF! error.


I know I can use VBA to insert “=AVERAGE(A1:A10)” back into the cell on Sheet2 once the deleting has been completed, but I have many formulas referencing that A1:A10 and most of them contain quotation marks. It’s slow to use VBA to reinsert these formulas every time I run the query and it’s going to be a headache writing up the code to insert each one of these and replacing all the quotations with double quotations, so I was wondering if there is a more efficient way.


And I must delete rows 1-10, I can’t just hide them.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Is there a way to delete rows with VBA without changing my cell references?


I’m doing a web query that I will refresh daily. For example, every time I pull data it populates column A for 20 rows. I then delete the first 10 rows. I then want to take the average of the remaining 10 rows. If I have the formula =AVERAGE(Sheet1!A1:A10) in a cell on Sheet2 then every time VBA deletes rows 1-10 the formula returns a #REF! error.


I know I can use VBA to insert “=AVERAGE(A1:A10)” back into the cell on Sheet2 once the deleting has been completed, but I have many formulas referencing that A1:A10 and most of them contain quotation marks. It’s slow to use VBA to reinsert these formulas every time I run the query and it’s going to be a headache writing up the code to insert each one of these and replacing all the quotations with double quotations, so I was wondering if there is a more efficient way.


And I must delete rows 1-10, I can’t just hide them.
Maybe this...

=AVERAGE(INDIRECT("Sheet1!A1:A10"))
 
Upvote 0

Forum statistics

Threads
1,207,438
Messages
6,078,561
Members
446,349
Latest member
Malroos7912

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