Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Cue Cue is offline
external usenet poster
 
Posts: 47
Default VBA - Selection Instead of Range

Hello,

The following code colors a row based on a cell value within that row.

Dim myCell2 As Range
Dim myrng2 As Range
Set myrng2 = Sheets("SORT").Range("$D$2:$D$240")

For Each myCell2 In myrng2.Cells

whatwant2 = myCell2.Value

For Each rcell In Sheets("SETUP").Range("$D$2:$D$20000")

If rcell.Value Like whatwant2 And rcell.Value 0 Then
rcell.EntireRow.Resize(1, 21).Interior.ColorIndex = 38
End If

Next rcell

Next myCell2


Instead of using Range for Set myrng2 & For Each rcell, I want the code to
use Selection. So if cells on both sheets, SORT & SETUP, I want the code to
search and color based on the selections. Can anyone show me how I can
accomplish this?

Thanks.
--
Cue
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 143
Default VBA - Selection Instead of Range

first i think you should chenge both range sets to use rnge names not cell
addrss. like-

Set myrng2 = Sheets("SORT").Range("SortSheetRg")

and

For Each rcell In Sheets("SETUP").Range("SetupSheetRg")


then befor you call this code you should create the names based on selection
in each sheet. like

sheets("sort").activate
selection.name = "SortSheetRg"
sheets("setup").activate
selection.name = "SetupSheetRg"


"Cue" wrote in message
...
| Hello,
|
| The following code colors a row based on a cell value within that row.
|
| Dim myCell2 As Range
| Dim myrng2 As Range
| Set myrng2 = Sheets("SORT").Range("$D$2:$D$240")
|
| For Each myCell2 In myrng2.Cells
|
| whatwant2 = myCell2.Value
|
| For Each rcell In Sheets("SETUP").Range("$D$2:$D$20000")
|
| If rcell.Value Like whatwant2 And rcell.Value 0 Then
| rcell.EntireRow.Resize(1, 21).Interior.ColorIndex = 38
| End If
|
| Next rcell
|
| Next myCell2
|
|
| Instead of using Range for Set myrng2 & For Each rcell, I want the code to
| use Selection. So if cells on both sheets, SORT & SETUP, I want the code
to
| search and color based on the selections. Can anyone show me how I can
| accomplish this?
|
| Thanks.
| --
| Cue

  #3   Report Post  
Posted to microsoft.public.excel.misc
Cue Cue is offline
external usenet poster
 
Posts: 47
Default VBA - Selection Instead of Range

Thanks Homey!
--
Cue


"Homey" wrote:

first i think you should chenge both range sets to use rnge names not cell
addrss. like-

Set myrng2 = Sheets("SORT").Range("SortSheetRg")

and

For Each rcell In Sheets("SETUP").Range("SetupSheetRg")


then befor you call this code you should create the names based on selection
in each sheet. like

sheets("sort").activate
selection.name = "SortSheetRg"
sheets("setup").activate
selection.name = "SetupSheetRg"


"Cue" wrote in message
...
| Hello,
|
| The following code colors a row based on a cell value within that row.
|
| Dim myCell2 As Range
| Dim myrng2 As Range
| Set myrng2 = Sheets("SORT").Range("$D$2:$D$240")
|
| For Each myCell2 In myrng2.Cells
|
| whatwant2 = myCell2.Value
|
| For Each rcell In Sheets("SETUP").Range("$D$2:$D$20000")
|
| If rcell.Value Like whatwant2 And rcell.Value 0 Then
| rcell.EntireRow.Resize(1, 21).Interior.ColorIndex = 38
| End If
|
| Next rcell
|
| Next myCell2
|
|
| Instead of using Range for Set myrng2 & For Each rcell, I want the code to
| use Selection. So if cells on both sheets, SORT & SETUP, I want the code
to
| search and color based on the selections. Can anyone show me how I can
| accomplish this?
|
| Thanks.
| --
| Cue

.

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
Range selection Naveen Excel Discussion (Misc queries) 3 October 9th 07 02:34 PM
Narrow Range based on Selection in Another Range David Excel Discussion (Misc queries) 3 July 1st 07 05:12 PM
Identifying a selection of a selection of a range swimfast Excel Worksheet Functions 1 March 1st 07 02:51 AM
Range Selection cfspahn24 Excel Discussion (Misc queries) 3 April 14th 06 01:29 PM
Selection Range ch Excel Discussion (Misc queries) 5 July 15th 05 05:50 AM


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