View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Richard Daniels Richard Daniels is offline
external usenet poster
 
Posts: 19
Default Looping thru cells in a named range

Hi

This will loop through all the cells in a named range and
copy the value and add = at the begining. If you just
want the copy the value of the cell the remove the "=" &
from the code.

Sub copyCellsInNamedRange()
Dim rng As Range

For Each rng In Sheets(1).Range("test")
rng.Formula = "=" & rng.Text
Next
'clean up
Application.CutCopyMode = False
Set rng = Nothing
End Sub


-----Original Message-----
Hi All,

I have a named range of non-adjacent cells and want to

perform the following
actions on each of the cells in that range.

Selection.Copy
Selection.PasteSpecial Paste:=xlValues
ActiveCell.Formula = "=" & ActiveCell.Text

Can anybody tell me / provide the code to do it ?

All help greatly appreciated.

Regards

Michael Beckinsale


.