Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Assigning New Name For Each Cell That Matches Criteria

Hi All,

I'm trying to build a macro that will check all the values in a range
to test which cells have a value greater than zero. Then for each
cell that does to name its address (in order) as Name+1 then Name+2
etc so that I can use Name+1 to return the address of that cell later
in another Macro.

I can check each cell without problem using For Each in Range and I
can test using If Then, however it is the nameing part that I can't
get, any help is as always greatly appreciated.

Best Regards,

CalumMurdo Kennedy
www.taekwondo.freeserve.co.uk
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Assigning New Name For Each Cell That Matches Criteria

For Each cell In Selection
If cell.Value 0 Then
i = i + 1
ActiveWorkbook.Names.Add Name:="Name" & i, _
RefersTo:="=" & cell.Address
End If
Next cell


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"CalumMurdo Kennedy" wrote in message
om...
Hi All,

I'm trying to build a macro that will check all the values in a range
to test which cells have a value greater than zero. Then for each
cell that does to name its address (in order) as Name+1 then Name+2
etc so that I can use Name+1 to return the address of that cell later
in another Macro.

I can check each cell without problem using For Each in Range and I
can test using If Then, however it is the nameing part that I can't
get, any help is as always greatly appreciated.

Best Regards,

CalumMurdo Kennedy
www.taekwondo.freeserve.co.uk



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Assigning New Name For Each Cell That Matches Criteria

'------------------------------------------
Sub test()
Dim MyRange As Range
Dim Counter As Integer
'--------------------
Set MyRange = ActiveSheet.Range("A1:A50")
Counter = 1
For Each c In MyRange.Cells
If c.Value 0 Then
ActiveSheet.Names.Add _
Name:="Name" & Counter, _
RefersTo:="=" & c.Address
Counter = Counter + 1
End If
Next
End Sub
'------------------------------------------------

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Assigning New Name For Each Cell That Matches Criteria

Thanks everyone for the very quick responses!

Best Regards,

CalumMurdo Kennedy
www.taekwondo.freeserve.co.uk

-----Original Message-----
'------------------------------------------
Sub test()
Dim MyRange As Range
Dim Counter As Integer
'--------------------
Set MyRange = ActiveSheet.Range("A1:A50")
Counter = 1
For Each c In MyRange.Cells
If c.Value 0 Then
ActiveSheet.Names.Add _
Name:="Name" & Counter, _
RefersTo:="=" & c.Address
Counter = Counter + 1
End If
Next
End Sub
'-------------------------------------------------


---
Message posted from http://www.ExcelForum.com/

.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Assigning New Name For Each Cell That Matches Criteria

or





-----Original Message-----
For Each cell In Selection
If cell.Value 0 Then
i = i + 1
ActiveWorkbook.Names.Add Name:="Name" & i, _
RefersTo:="=" &

cell.Address
End If
Next cell


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
For Each cell In Selection

If cell.Value 0 Then
i = i + 1
Cell.Name = "Name" & i
End If
Next cell
"CalumMurdo Kennedy" wrote in

message
. com...
Hi All,

I'm trying to build a macro that will check all the

values in a range
to test which cells have a value greater than zero.

Then for each
cell that does to name its address (in order) as

Name+1 then Name+2
etc so that I can use Name+1 to return the address of

that cell later
in another Macro.

I can check each cell without problem using For Each

in Range and I
can test using If Then, however it is the nameing part

that I can't
get, any help is as always greatly appreciated.

Best Regards,

CalumMurdo Kennedy
www.taekwondo.freeserve.co.uk



.



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
If value matches criteria, return formula DJ Excel Worksheet Functions 3 October 8th 09 05:21 PM
Get last 6 rows in list where 1 cell matches certain criteria Struggling in Sheffield[_2_] New Users to Excel 2 March 13th 09 12:54 AM
i need to get all matches in one column for one criteria PERANISH Excel Worksheet Functions 2 November 13th 08 12:40 AM
SumIf Criteria Matches Debbie Dies Excel Worksheet Functions 4 August 1st 05 11:18 PM
Is it possible to do a vertical lookup that matches on 2 criteria lshaw Excel Worksheet Functions 4 May 16th 05 07:00 PM


All times are GMT +1. The time now is 04:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"