Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 594
Default Find value, then Create a Range

Hi All..........

If someone would be so kind.........is it possible for a macro to do a
"find" in column A for the value in M1, and then if found, create a
NamedRange using the word RANGEand concatenating the value in M1 on the end
of it, and causing the range thereby created to be 14 rows below and 4
columns to the right of the found cell, including the found cell.

If so, here's what I would really like to do:
Say M1=30210 (greater than zero), then when the macro starts, search for
30210 in column A (say it's found in A4), copy that value down the next 14
rows, then create a range from A4:E18 and name it RANGE30210.......then,
apply a heavy black border around the range and color it's cells
yellow.......terminate without looking for a second occurance.

If 30210 is not found in column A, then just color M1 RED and terminate the
macro.


TIA for any help
Vaya con Dios,
Chuck, CABGx3



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Find value, then Create a Range

I haven't tested this, so it may be buggy...

Sub FindIt()
With ActiveSheet
Set M1 = Range("M1")
Set Rng = .Range("A:A").Find(M1.Value)
End With

If Rng Is Nothing Then
With M1
'put code here to set the color and borders
End With
Else
Set Rng = Rng.Resize(15, 5)
With Rng
.Name = "RANGE" & M1.Value
'put code here to set the color and borders
End With
End If
End Sub

On Tue, 16 Nov 2004 20:17:14 -0500, "CLR" wrote:

Hi All..........

If someone would be so kind.........is it possible for a macro to do a
"find" in column A for the value in M1, and then if found, create a
NamedRange using the word RANGEand concatenating the value in M1 on the end
of it, and causing the range thereby created to be 14 rows below and 4
columns to the right of the found cell, including the found cell.

If so, here's what I would really like to do:
Say M1=30210 (greater than zero), then when the macro starts, search for
30210 in column A (say it's found in A4), copy that value down the next 14
rows, then create a range from A4:E18 and name it RANGE30210.......then,
apply a heavy black border around the range and color it's cells
yellow.......terminate without looking for a second occurance.

If 30210 is not found in column A, then just color M1 RED and terminate the
macro.


TIA for any help
Vaya con Dios,
Chuck, CABGx3



  #3   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 594
Default Find value, then Create a Range

Really really COOL Myrna.............thank you VERY much.............your
code solves the major problems and works just dandy, and is so simple, even
I can understand most of it.........

Thanks muchly again,
Vaya con Dios,
Chuck, CABGx3



"Myrna Larson" wrote in message
...
I haven't tested this, so it may be buggy...

Sub FindIt()
With ActiveSheet
Set M1 = Range("M1")
Set Rng = .Range("A:A").Find(M1.Value)
End With

If Rng Is Nothing Then
With M1
'put code here to set the color and borders
End With
Else
Set Rng = Rng.Resize(15, 5)
With Rng
.Name = "RANGE" & M1.Value
'put code here to set the color and borders
End With
End If
End Sub

On Tue, 16 Nov 2004 20:17:14 -0500, "CLR"

wrote:

Hi All..........

If someone would be so kind.........is it possible for a macro to do a
"find" in column A for the value in M1, and then if found, create a
NamedRange using the word RANGEand concatenating the value in M1 on the

end
of it, and causing the range thereby created to be 14 rows below and 4
columns to the right of the found cell, including the found cell.

If so, here's what I would really like to do:
Say M1=30210 (greater than zero), then when the macro starts, search for
30210 in column A (say it's found in A4), copy that value down the next

14
rows, then create a range from A4:E18 and name it RANGE30210.......then,
apply a heavy black border around the range and color it's cells
yellow.......terminate without looking for a second occurance.

If 30210 is not found in column A, then just color M1 RED and terminate

the
macro.


TIA for any help
Vaya con Dios,
Chuck, CABGx3





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
Find Last cell in Range when range is date format default105 Excel Discussion (Misc queries) 5 July 7th 09 03:11 PM
Find the MAX number in range, then find... pgarcia Excel Discussion (Misc queries) 4 September 19th 08 06:58 PM
Find a range of values in a range of cells Jack Taylor Excel Worksheet Functions 20 November 25th 06 01:26 PM
Find dates in a range; then sum values in that range by a criteria Anders Excel Discussion (Misc queries) 4 October 21st 05 03:41 PM
Range.Find returns cell outside of range when range set to single cell Frank Jones Excel Programming 12 June 10th 04 04:22 AM


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