View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default How can I replace a formula with its result using a macro?

Hi Randy,

To operate on another worksheet in the current workbook:

Set rng = Sheets("SheetName").Range("A20:K20")

or, more explicitly (and, therefore, better):

Set rng = ActiveWorkbook.Sheets("SheetName").Range("A20:K20" )


To operate on a worksheet in an open workbook other than the current
workbook:

Set rng = Workbooks("Name.xls").Sheets("SheetName").Range("A 20:K20")

Setting the range object (rng) in this way obviates the need physically to
select another worksheet or workbook: all the manipulation can be effected
using the object. Such remote manipulation represents good Excel programming
practice and is invariably more efficient than the corresponding selection
method.


---
Regards,
Norman



"RAP" wrote in message
...
One more question, if you please.

On this line:
Set rng = ActiveSheet.Range("A20:K20")
What would I insert to go from the active sheet to another sheet in the
workbook?

Thank you,
Randy