Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 68
Default How to "return" the array element number in VBA

2003

Challenge:

For Each myCell in myRange
.....
.....
'Would like to be able to move to the next myCell in a (non-contiguous)
'myRange if the current myCell.Value = 0. I do not know how to return
'the current myCell array element number AND to increment to the next
'non-zero "0" myCell.value
.....
.......
Next myCell

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default How to "return" the array element number in VBA

I think you are going to have a problem here... You are in a "For Each"
statement which by it's very nature requires you to go through each and every
element... No skipping allowed...
--
HTH...

Jim Thomlinson


"EagleOne" wrote:

2003

Challenge:

For Each myCell in myRange
.....
.....
'Would like to be able to move to the next myCell in a (non-contiguous)
'myRange if the current myCell.Value = 0. I do not know how to return
'the current myCell array element number AND to increment to the next
'non-zero "0" myCell.value
.....
.......
Next myCell


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default How to "return" the array element number in VBA

Maybe you don't have to move at all. Maybe you can just do the work you want on
the non-zero values.

dim myCell as range
dim myRange as range

'set myRange = somerangehere

for each mycell in myrange.cells
if mycell.value = 0 then
'do nothing
else
mycell.value = mycell.value + 1 'whatever increment
end if
next mycell



EagleOne wrote:

2003

Challenge:

For Each myCell in myRange
....
....
'Would like to be able to move to the next myCell in a (non-contiguous)
'myRange if the current myCell.Value = 0. I do not know how to return
'the current myCell array element number AND to increment to the next
'non-zero "0" myCell.value
....
......
Next myCell


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 68
Default How to "return" the array element number in VBA

No wonder I could not find out how to skip!

Thanks Jim


Jim Thomlinson wrote:
I think you are going to have a problem here... You are in a "For Each"
statement which by it's very nature requires you to go through each and every
element... No skipping allowed...
--
HTH...

Jim Thomlinson


"EagleOne" wrote:

2003

Challenge:

For Each myCell in myRange
.....
.....
'Would like to be able to move to the next myCell in a (non-contiguous)
'myRange if the current myCell.Value = 0. I do not know how to return
'the current myCell array element number AND to increment to the next
'non-zero "0" myCell.value
.....
.......
Next myCell



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 68
Default How to "return" the array element number in VBA

Thanks Dave. It has been a tough week. I did not see the forest for
the trees.

BTW, your guidance this week or so, is/was greatly appreciated

Dennis

Dave Peterson wrote:
Maybe you don't have to move at all. Maybe you can just do the work you want on
the non-zero values.

dim myCell as range
dim myRange as range

'set myRange = somerangehere

for each mycell in myrange.cells
if mycell.value = 0 then
'do nothing
else
mycell.value = mycell.value + 1 'whatever increment
end if
next mycell



EagleOne wrote:

2003

Challenge:

For Each myCell in myRange
....
....
'Would like to be able to move to the next myCell in a (non-contiguous)
'myRange if the current myCell.Value = 0. I do not know how to return
'the current myCell array element number AND to increment to the next
'non-zero "0" myCell.value
....
......
Next myCell


--

Dave Peterson


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
row number question in an array SD Excel Worksheet Functions 10 December 8th 07 06:07 PM
How do I set up a 6 day work week in Excel? rrichter Excel Worksheet Functions 9 August 13th 06 07:05 PM
number anagram spyshot Excel Worksheet Functions 9 February 22nd 06 06:18 PM
Permutations of an array element < to a value Bruce Excel Worksheet Functions 3 January 31st 06 04:00 PM
Array Formulas take waaaay too long... belly0fdesire Excel Worksheet Functions 7 August 8th 05 10:11 PM


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