Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default loop through looking for value

Howdie all.
I have a macro that loops through a series of worksheets and sets an
ascending numeric value in the first column-- offsetting 5 rows for each
subsequent ascending number placement.
There are, from time to time, "Info Only" values in specific cells that we
need to retain. I.e., in A10 is the value- Info, and in A11 is "Only," then
say- 25 rows down is a repeat at A35, and A36. But the placement of Info Only
is random, and cannot be a hard value placement.
What I'm trying to do is to have my macro look through the values, and if it
finds INFO, skip the 5 cell range, and go to the next 5 cell range, where it
places a numeric value.
My thinking was:

for each mycell in myRng
if mycell.value = "info" then
mycell.offset(5,0)
end if
next mycell

The balance of the macro works great, and does exactly what we need it to--
place ascending numeric values in the correct column, and cycle through each
worksheet in the file doing the same on each.
However, I've missed something here as it's not working. I've tried a few
variations, for which I receive 1004, 438, 7, and 91 runtime errors.
In the reading I've done here on the newsgroups, and in the helpfile, I just
keep missing it.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default loop through looking for value

Unless you left out some code, this isn't going to do anything. Say your
range is A1 to A10, if it finds "info" in say A3, it does the offset and end
if, but the next forces it to the next cell in the range (A4). If you are
wanting to take that offset and do something with it, you would exit for
first.
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"SteveDB1" wrote:

Howdie all.
I have a macro that loops through a series of worksheets and sets an
ascending numeric value in the first column-- offsetting 5 rows for each
subsequent ascending number placement.
There are, from time to time, "Info Only" values in specific cells that we
need to retain. I.e., in A10 is the value- Info, and in A11 is "Only," then
say- 25 rows down is a repeat at A35, and A36. But the placement of Info Only
is random, and cannot be a hard value placement.
What I'm trying to do is to have my macro look through the values, and if it
finds INFO, skip the 5 cell range, and go to the next 5 cell range, where it
places a numeric value.
My thinking was:

for each mycell in myRng
if mycell.value = "info" then
mycell.offset(5,0)
end if
next mycell

The balance of the macro works great, and does exactly what we need it to--
place ascending numeric values in the correct column, and cycle through each
worksheet in the file doing the same on each.
However, I've missed something here as it's not working. I've tried a few
variations, for which I receive 1004, 438, 7, and 91 runtime errors.
In the reading I've done here on the newsgroups, and in the helpfile, I just
keep missing it.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default loop through looking for value

Morning John.
My goal was to have it look for the word-- info-- and then offset if it
found the word, and if it did not find it, to move along to previously coded
processes--- in this case, input the numeric value.


"John Bundy" wrote:

Unless you left out some code, this isn't going to do anything. Say your
range is A1 to A10, if it finds "info" in say A3, it does the offset and end
if, but the next forces it to the next cell in the range (A4). If you are
wanting to take that offset and do something with it, you would exit for
first.
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"SteveDB1" wrote:

Howdie all.
I have a macro that loops through a series of worksheets and sets an
ascending numeric value in the first column-- offsetting 5 rows for each
subsequent ascending number placement.
There are, from time to time, "Info Only" values in specific cells that we
need to retain. I.e., in A10 is the value- Info, and in A11 is "Only," then
say- 25 rows down is a repeat at A35, and A36. But the placement of Info Only
is random, and cannot be a hard value placement.
What I'm trying to do is to have my macro look through the values, and if it
finds INFO, skip the 5 cell range, and go to the next 5 cell range, where it
places a numeric value.
My thinking was:

for each mycell in myRng
if mycell.value = "info" then
mycell.offset(5,0)
end if
next mycell

The balance of the macro works great, and does exactly what we need it to--
place ascending numeric values in the correct column, and cycle through each
worksheet in the file doing the same on each.
However, I've missed something here as it's not working. I've tried a few
variations, for which I receive 1004, 438, 7, and 91 runtime errors.
In the reading I've done here on the newsgroups, and in the helpfile, I just
keep missing it.

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
returning back to loop check condition without completing the loop ashish128 Excel Programming 13 April 3rd 08 12:53 PM
Loop to Filter, Name Sheets. If Blank, Exit Loop ryguy7272 Excel Programming 3 February 5th 08 03:41 PM
Naming Worksheets - Loop within a loop issue klysell Excel Programming 5 March 29th 07 05:48 AM
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM


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