#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 47
Default Selection Address

XL2003
How can I use a selection address from sheet1 as a range on sheet 2?

I want to select a range of cells on sheet1, then click on a command button
and have the same range selected on sheet2 so I can run another procedure on
that range.

I have this code that works on a selection from the same sheet.
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
Private Sub cmd1_Click()

For Each c In Selection
If c.Font.ColorIndex = 3 Then ms = ms + c
Next
For Each c In Selection
If c.Interior.ColorIndex = 38 Then ms = ms * 2
Next
For Each c In Selection
If c.Interior.ColorIndex = 3 Then ms = ms * 3
Next
MsgBox ms
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Selection Address

Hi,

Assume that (say) sheet 1 is the active sheet and you have a range of cells
selected. This will loop through the same range of cells on sheet 2. Sheet 1
must remain the active sheet.

Sub Sonic()
For Each c In Sheets("Sheet2").Range(Selection.Address)
MsgBox c.Value
Next
End Sub


Mike


"Gizmo" wrote:

XL2003
How can I use a selection address from sheet1 as a range on sheet 2?

I want to select a range of cells on sheet1, then click on a command button
and have the same range selected on sheet2 so I can run another procedure on
that range.

I have this code that works on a selection from the same sheet.
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''
Private Sub cmd1_Click()

For Each c In Selection
If c.Font.ColorIndex = 3 Then ms = ms + c
Next
For Each c In Selection
If c.Interior.ColorIndex = 38 Then ms = ms * 2
Next
For Each c In Selection
If c.Interior.ColorIndex = 3 Then ms = ms * 3
Next
MsgBox ms
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''

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
Code to send email to address within selection in Excel workbook vic1 Excel Discussion (Misc queries) 3 May 28th 08 09:51 PM
Copy Selection - Transpose Selection - Delete Selection Uninvisible Excel Discussion (Misc queries) 2 October 23rd 07 04:18 PM
How do I avoid excel change absolute address to relative address Miguel Excel Discussion (Misc queries) 3 May 10th 07 11:18 PM
long address list, name-address-city, listed vertically, how do y. kb Excel Discussion (Misc queries) 2 March 4th 05 12:48 AM
How do I import Office address book to Outlook Express address bo. snnorp Excel Discussion (Misc queries) 2 February 22nd 05 11:47 AM


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