Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
worksheet selection
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
worksheet selection
Check this out:
http://support.microsoft.com/kb/141762 "greg" wrote: 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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
worksheet selection
This is a valid approach and works for me. The problem may possibly be that
the macro is in the wrong place? It should be in a module rather than behind a worksheet. -- Tim Zych www.higherdata.com Compare data in workbooks and find differences with Workbook Compare A free, powerful, flexible Excel utility "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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Prevent worksheet selection | Excel Discussion (Misc queries) | |||
Lock worksheet, based on dropdown selection prior worksheet | New Users to Excel | |||
worksheet selection count | Excel Programming | |||
Worksheet, selection macro | Excel Worksheet Functions | |||
Worksheet Selection | Excel Programming |