View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones[_2_] Norman Jones[_2_] is offline
external usenet poster
 
Posts: 421
Default worksheet selection

Hi Greg,

Your code works for me and I am not sure
that I understand the question.

Perhaps, try something like:

'=============
Public Sub Tester()
Dim WB As Workbook
Dim SH As Worksheet
Dim Rng As Range
Dim rCell As Range

Set WB = Workbooks("MyBook1.xls") '<<==== CHANGE
Set SH = WB.Sheets("Foglio1") '<<==== CHANGE
Set Rng = SH.Range("A1:A10") '<<==== CHANGE

For Each rCell In Rng.Cells
'\\ Do something, e.g.
MsgBox Prompt:=rCell.Address(0, 0)
Next rCell
End Sub
'<<=============


---
Regards.
Norman
"greg" wrote in message
...
If I have a few cells selected. And I have a worksheet object to work
with.
How can I loop the selected cells?

I normally do
Dim myCell As Range
For Each myCell In Selection.Cells

However from a worksheet, it does not seem like there is a selection.

thanks foe any help