Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 97
Default I am soooo sorry


For each c in selection
c.value = "Don"
Next c

"Don Cardoza" wrote in message
...
to bother everyone with a very simple question, but I've been trying for
without success

I know how to refer to a specific range like this:

For Each c In ActiveSheet.Range("d2:e14").Cells
c.Value = "Don"
Next

I can refer to a currentRegion too

For Each c In ActiveCell.CurrentRegion.Cells
c.Value = "Don"
Next

What I can't seem to do is apply this to a range of cells selected by the
user

I've tried different variations of ActiveWindow.RangeSelection.Address but
have failed

something like...
set myrange=ActiveWindow.RangeSelection.Address
For Each c In ActiveSheet.Range(myrange).Cells
c.Value = "Don"
Next

My sincerest apology to bother everyone for what should seem like a
trivial
task




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default I am soooo sorry

The object you are looking for is simply Selection eg:

For Each c In Selection
c.Value = "Don"
Next

but you need to bear in mind that Selection may not refer to a range
(the user may have selected a chart for example) so you probably want:

If TypeName(Selection) = "Range" Then
For Each c In Selection
c.Value = "Don"
Next
End If

Hope this helps
Rowan

Don Cardoza wrote:
to bother everyone with a very simple question, but I've been trying for
without success

I know how to refer to a specific range like this:

For Each c In ActiveSheet.Range("d2:e14").Cells
c.Value = "Don"
Next

I can refer to a currentRegion too

For Each c In ActiveCell.CurrentRegion.Cells
c.Value = "Don"
Next

What I can't seem to do is apply this to a range of cells selected by the
user

I've tried different variations of ActiveWindow.RangeSelection.Address but
have failed

something like...
set myrange=ActiveWindow.RangeSelection.Address
For Each c In ActiveSheet.Range(myrange).Cells
c.Value = "Don"
Next

My sincerest apology to bother everyone for what should seem like a trivial
task


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default I am soooo sorry


try this:

For each c in Selection
<whatever you want to do
Next


The user can then select the items he/she wants to run this for an
click start etc.

cheers

--
lithium8
-----------------------------------------------------------------------
lithium81's Profile: http://www.excelforum.com/member.php...fo&userid=2946
View this thread: http://www.excelforum.com/showthread.php?threadid=49170

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default I am soooo sorry

to bother everyone with a very simple question, but I've been trying for
without success

I know how to refer to a specific range like this:

For Each c In ActiveSheet.Range("d2:e14").Cells
c.Value = "Don"
Next

I can refer to a currentRegion too

For Each c In ActiveCell.CurrentRegion.Cells
c.Value = "Don"
Next

What I can't seem to do is apply this to a range of cells selected by the
user

I've tried different variations of ActiveWindow.RangeSelection.Address but
have failed

something like...
set myrange=ActiveWindow.RangeSelection.Address
For Each c In ActiveSheet.Range(myrange).Cells
c.Value = "Don"
Next

My sincerest apology to bother everyone for what should seem like a trivial
task


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default I am soooo sorry

Another option:
'// Make sure a Range is selected...
If TypeName(Selection) = "Range" Then Selection = "Don"

HTH. :)
--
Dana DeLouis
Win XP & Office 2003


"Don Cardoza" wrote in message
...
to bother everyone with a very simple question, but I've been trying for
without success

I know how to refer to a specific range like this:

For Each c In ActiveSheet.Range("d2:e14").Cells
c.Value = "Don"
Next

I can refer to a currentRegion too

For Each c In ActiveCell.CurrentRegion.Cells
c.Value = "Don"
Next

What I can't seem to do is apply this to a range of cells selected by the
user

I've tried different variations of ActiveWindow.RangeSelection.Address but
have failed

something like...
set myrange=ActiveWindow.RangeSelection.Address
For Each c In ActiveSheet.Range(myrange).Cells
c.Value = "Don"
Next

My sincerest apology to bother everyone for what should seem like a
trivial
task






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default I am soooo sorry

And another:
ActiveWindow.RangeSelection.Value = "DaDooRonRon"

HTH. Best wishes Harald

"Don Cardoza" skrev i melding
...
to bother everyone with a very simple question, but I've been trying for
without success

I know how to refer to a specific range like this:

For Each c In ActiveSheet.Range("d2:e14").Cells
c.Value = "Don"
Next

I can refer to a currentRegion too

For Each c In ActiveCell.CurrentRegion.Cells
c.Value = "Don"
Next

What I can't seem to do is apply this to a range of cells selected by the
user

I've tried different variations of ActiveWindow.RangeSelection.Address but
have failed

something like...
set myrange=ActiveWindow.RangeSelection.Address
For Each c In ActiveSheet.Range(myrange).Cells
c.Value = "Don"
Next

My sincerest apology to bother everyone for what should seem like a

trivial
task




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



All times are GMT +1. The time now is 01:40 AM.

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"