Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Prevent worksheet selection OxonLad Excel Discussion (Misc queries) 2 October 15th 09 05:54 PM
Lock worksheet, based on dropdown selection prior worksheet Michele New Users to Excel 9 June 21st 09 10:31 PM
worksheet selection count Kelzina Excel Programming 3 November 20th 06 10:31 AM
Worksheet, selection macro Steve Excel Worksheet Functions 5 November 2nd 06 01:26 AM
Worksheet Selection Gazza Excel Programming 3 May 5th 05 05:45 PM


All times are GMT +1. The time now is 07:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"