Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 265
Default Set the selected range myrange

Hi, tryng something easy but I don't figure out how to accomplish it, what I
have until now:
Sub Macro2()
Dim myrange As Range, rng As Range
a = 1
Set myrange = (THE SELECTED RANGE IN THE SHEET)
For Each rng In myrange
Cells(a + rng.Row, rng.Column) = Cells(2 + rng.Row, rng.Column)
a = a + 1
Next rng
End Sub
What I want to accomplish is:
The user selects a range (ex. "d22:d25") and write a number (ex. 10 (that
automatically is writen in cell "d22")) then, when the user press enter the
number 10 appears in the d22:d25 range
TIA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Set the selected range myrange

Sub Macro2()
Dim myrange As Range
Set myrange = Selection
myrange.Value = myrange(1).Value
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"filo666" wrote in message
...
Hi, tryng something easy but I don't figure out how to accomplish it, what

I
have until now:
Sub Macro2()
Dim myrange As Range, rng As Range
a = 1
Set myrange = (THE SELECTED RANGE IN THE SHEET)
For Each rng In myrange
Cells(a + rng.Row, rng.Column) = Cells(2 + rng.Row, rng.Column)
a = a + 1
Next rng
End Sub
What I want to accomplish is:
The user selects a range (ex. "d22:d25") and write a number (ex. 10 (that
automatically is writen in cell "d22")) then, when the user press enter

the
number 10 appears in the d22:d25 range
TIA



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Set the selected range myrange


Hello Filo666,

Sub Macro2()

Dim Cell
Dim MyRange As Range
Dim Num

Num = ActiveCell.Value

Set MyRange = ActiveSheet.Selection

For Each Cell in MyRange
Cell = Num
Next Cell

End Sub

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=497723

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 265
Default Set the selected range myrange

thanks, just one problem, remember that the macro iut's going to be runed in
a worksheet_change event, so I need to use target because if I useselection
then when the user press enter the selection is the next cell of target¡¡¡¡¡


"Bob Phillips" wrote:

Sub Macro2()
Dim myrange As Range
Set myrange = Selection
myrange.Value = myrange(1).Value
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"filo666" wrote in message
...
Hi, tryng something easy but I don't figure out how to accomplish it, what

I
have until now:
Sub Macro2()
Dim myrange As Range, rng As Range
a = 1
Set myrange = (THE SELECTED RANGE IN THE SHEET)
For Each rng In myrange
Cells(a + rng.Row, rng.Column) = Cells(2 + rng.Row, rng.Column)
a = a + 1
Next rng
End Sub
What I want to accomplish is:
The user selects a range (ex. "d22:d25") and write a number (ex. 10 (that
automatically is writen in cell "d22")) then, when the user press enter

the
number 10 appears in the d22:d25 range
TIA




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Set the selected range myrange

Worksheet_Change or Worksheet_SelectionChange? If the former, you don't need
the code as you could select a range, enter 10 aand then use Ctrl-Enter to
get the value in all the cells. If the letter, then how do you get the value
to set it all to? If it is already in the first cell then just change Target
for Selection.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"filo666" wrote in message
...
thanks, just one problem, remember that the macro iut's going to be runed

in
a worksheet_change event, so I need to use target because if I

useselection
then when the user press enter the selection is the next cell of

target¡¡¡¡¡


"Bob Phillips" wrote:

Sub Macro2()
Dim myrange As Range
Set myrange = Selection
myrange.Value = myrange(1).Value
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"filo666" wrote in message
...
Hi, tryng something easy but I don't figure out how to accomplish it,

what
I
have until now:
Sub Macro2()
Dim myrange As Range, rng As Range
a = 1
Set myrange = (THE SELECTED RANGE IN THE SHEET)
For Each rng In myrange
Cells(a + rng.Row, rng.Column) = Cells(2 + rng.Row, rng.Column)
a = a + 1
Next rng
End Sub
What I want to accomplish is:
The user selects a range (ex. "d22:d25") and write a number (ex. 10

(that
automatically is writen in cell "d22")) then, when the user press

enter
the
number 10 appears in the d22:d25 range
TIA






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
Why Copy/Paste fails using Offset & Resize of myRange? [email protected] Excel Discussion (Misc queries) 3 November 21st 06 02:06 AM
Set MyRange for non-adjacent cells and iterate through? Ed Excel Programming 2 January 3rd 06 06:13 PM
Compare a selected Range with a Named range and select cells that do not exist PCLIVE Excel Programming 1 October 18th 05 07:09 PM
Help ASAP myRange VBA[_2_] Excel Programming 0 November 15th 04 10:33 PM
Why doesn't "Workbook.Range("myrange").value" work? Brad Patterson Excel Programming 0 July 9th 03 01:24 AM


All times are GMT +1. The time now is 04:30 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"