#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default loop

Somewhere in column F i have the value "Production". It could be in
F100 or F157. It is not known.
My cursor is in cell G7. I am using activecell.offset(1,0).select to
scroll downwards. I want to move my cursor in column G only till the
row where the cell value in column F is "Production" what would be the
syntax?

something like While Not Cells(row, 6).Value = "Production"

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 222
Default loop

How about

Do While Not ActiveCell.Offset(0, -1).Value = "Production"
ActiveCell.Offset(1, 0).Select
Loop

" wrote:

Somewhere in column F i have the value "Production". It could be in
F100 or F157. It is not known.
My cursor is in cell G7. I am using activecell.offset(1,0).select to
scroll downwards. I want to move my cursor in column G only till the
row where the cell value in column F is "Production" what would be the
syntax?

something like While Not Cells(row, 6).Value = "Production"


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default loop

Sub Prod()
Dim MyRange As Range
Set MyRange = Range("G7:G100") ' adjust as needed
For Each cell In MyRange
If cell.Offset(0, -1).Value = "Production" Then
cell.Select
Exit Sub
End If
Next
End Sub

wrote:
Somewhere in column F i have the value "Production". It could be in
F100 or F157. It is not known.
My cursor is in cell G7. I am using activecell.offset(1,0).select to
scroll downwards. I want to move my cursor in column G only till the
row where the cell value in column F is "Production" what would be the
syntax?

something like While Not Cells(row, 6).Value = "Production"


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default loop

thanx

acampbell wrote:
Sub Prod()
Dim MyRange As Range
Set MyRange = Range("G7:G100") ' adjust as needed
For Each cell In MyRange
If cell.Offset(0, -1).Value = "Production" Then
cell.Select
Exit Sub
End If
Next
End Sub

wrote:
Somewhere in column F i have the value "Production". It could be in
F100 or F157. It is not known.
My cursor is in cell G7. I am using activecell.offset(1,0).select to
scroll downwards. I want to move my cursor in column G only till the
row where the cell value in column F is "Production" what would be the
syntax?

something like While Not Cells(row, 6).Value = "Production"


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default loop

Don,

Good point. Max, if not tested already, this will stop and exist on the
first occurence. If it is slow or you need to continue the search, post
back.

Alan

Don Guillett wrote:
Looping will be slower than FIND. Look in the vba help. If more than one
then use FINDNEXT.

--
Don Guillett
SalesAid Software

wrote in message
oups.com...
Somewhere in column F i have the value "Production". It could be in
F100 or F157. It is not known.
My cursor is in cell G7. I am using activecell.offset(1,0).select to
scroll downwards. I want to move my cursor in column G only till the
row where the cell value in column F is "Production" what would be the
syntax?

something like While Not Cells(row, 6).Value = "Production"


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default loop

Don,

Good point. This uses find instead.


Dim MyRange As Range
Dim MyFind
Set MyRange = Range("F7:F100") ' adjust as needed
Set MyFind = MyRange.Find(What:="Production", LookIn:=xlValues)
If Not MyFind Is Nothing Then
Range(MyFind.Address).Offset(0, 1).Select
Exit Sub
End If
End Sub



Don Guillett wrote:
Looping will be slower than FIND. Look in the vba help. If more than one
then use FINDNEXT.

--
Don Guillett
SalesAid Software

wrote in message
oups.com...
Somewhere in column F i have the value "Production". It could be in
F100 or F157. It is not known.
My cursor is in cell G7. I am using activecell.offset(1,0).select to
scroll downwards. I want to move my cursor in column G only till the
row where the cell value in column F is "Production" what would be the
syntax?

something like While Not Cells(row, 6).Value = "Production"


  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default loop

Any advice on more efficient/effective coding is always welcome.

Directly trying to use the results of a method that could result in an error
as done in the example would be a poor approach. Even if you are sure the
sought value is present, failure to account for persistent values of
arguments to that method could again result in an error or inconsistent
results.

--
Regards,
Tom Ogilvy


"acampbell" wrote in message
oups.com...
Another good point. I am much more a student than a teacher out here.
Any advice on more efficient/effective coding is always welcome.

Thanks.

Alan

Don Guillett wrote:
or. But,why select???

Sub findit1()
'On Error Resume Next 'uncomment if you don't want error if not found
Cells(Range("f7:f100").Find("Production").Row + 1, "F").Select
End Sub


--
Don Guillett
SalesAid Software

"acampbell" wrote in message
ups.com...
Don,

Good point. This uses find instead.


Dim MyRange As Range
Dim MyFind
Set MyRange = Range("F7:F100") ' adjust as needed
Set MyFind = MyRange.Find(What:="Production", LookIn:=xlValues)
If Not MyFind Is Nothing Then
Range(MyFind.Address).Offset(0, 1).Select
Exit Sub
End If
End Sub



Don Guillett wrote:
Looping will be slower than FIND. Look in the vba help. If more than
one
then use FINDNEXT.

--
Don Guillett
SalesAid Software

wrote in message
oups.com...
Somewhere in column F i have the value "Production". It could be in
F100 or F157. It is not known.
My cursor is in cell G7. I am using activecell.offset(1,0).select to
scroll downwards. I want to move my cursor in column G only till the
row where the cell value in column F is "Production" what would be
the
syntax?

something like While Not Cells(row, 6).Value = "Production"







  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default loop

Tom,

I read your response and looked in to other posts in which "persistent
values" may have contributed to errors in results or routines. Below
is a snippet of a response you provided in another thread. Would it be
good practice to employ this suggestion in any find operation?

....After looking at your code, I would suggest you provide all
arguments to the find function. Several of the arguments have
persistent
values and could be causing the find operation to fail mysteriously...

Thanks.

Alan




Tom Ogilvy wrote:
Any advice on more efficient/effective coding is always welcome.


Directly trying to use the results of a method that could result in an error
as done in the example would be a poor approach. Even if you are sure the
sought value is present, failure to account for persistent values of
arguments to that method could again result in an error or inconsistent
results.

--
Regards,
Tom Ogilvy


"acampbell" wrote in message
oups.com...
Another good point. I am much more a student than a teacher out here.
Any advice on more efficient/effective coding is always welcome.

Thanks.

Alan

Don Guillett wrote:
or. But,why select???

Sub findit1()
'On Error Resume Next 'uncomment if you don't want error if not found
Cells(Range("f7:f100").Find("Production").Row + 1, "F").Select
End Sub


--
Don Guillett
SalesAid Software

"acampbell" wrote in message
ups.com...
Don,

Good point. This uses find instead.


Dim MyRange As Range
Dim MyFind
Set MyRange = Range("F7:F100") ' adjust as needed
Set MyFind = MyRange.Find(What:="Production", LookIn:=xlValues)
If Not MyFind Is Nothing Then
Range(MyFind.Address).Offset(0, 1).Select
Exit Sub
End If
End Sub



Don Guillett wrote:
Looping will be slower than FIND. Look in the vba help. If more than
one
then use FINDNEXT.

--
Don Guillett
SalesAid Software

wrote in message
oups.com...
Somewhere in column F i have the value "Production". It could be in
F100 or F157. It is not known.
My cursor is in cell G7. I am using activecell.offset(1,0).select to
scroll downwards. I want to move my cursor in column G only till the
row where the cell value in column F is "Production" what would be
the
syntax?

something like While Not Cells(row, 6).Value = "Production"




  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default loop

easy to find in the vba help index for FIND or FINDNEXT

--
Don Guillett
SalesAid Software

"acampbell" wrote in message
ups.com...
Tom,

I read your response and looked in to other posts in which "persistent
values" may have contributed to errors in results or routines. Below
is a snippet of a response you provided in another thread. Would it be
good practice to employ this suggestion in any find operation?

...After looking at your code, I would suggest you provide all
arguments to the find function. Several of the arguments have
persistent
values and could be causing the find operation to fail mysteriously...

Thanks.

Alan




Tom Ogilvy wrote:
Any advice on more efficient/effective coding is always welcome.


Directly trying to use the results of a method that could result in an
error
as done in the example would be a poor approach. Even if you are sure
the
sought value is present, failure to account for persistent values of
arguments to that method could again result in an error or inconsistent
results.

--
Regards,
Tom Ogilvy


"acampbell" wrote in message
oups.com...
Another good point. I am much more a student than a teacher out here.
Any advice on more efficient/effective coding is always welcome.

Thanks.

Alan

Don Guillett wrote:
or. But,why select???

Sub findit1()
'On Error Resume Next 'uncomment if you don't want error if not found
Cells(Range("f7:f100").Find("Production").Row + 1, "F").Select
End Sub


--
Don Guillett
SalesAid Software

"acampbell" wrote in message
ups.com...
Don,

Good point. This uses find instead.


Dim MyRange As Range
Dim MyFind
Set MyRange = Range("F7:F100") ' adjust as needed
Set MyFind = MyRange.Find(What:="Production", LookIn:=xlValues)
If Not MyFind Is Nothing Then
Range(MyFind.Address).Offset(0, 1).Select
Exit Sub
End If
End Sub



Don Guillett wrote:
Looping will be slower than FIND. Look in the vba help. If more
than
one
then use FINDNEXT.

--
Don Guillett
SalesAid Software

wrote in message
oups.com...
Somewhere in column F i have the value "Production". It could be
in
F100 or F157. It is not known.
My cursor is in cell G7. I am using activecell.offset(1,0).select
to
scroll downwards. I want to move my cursor in column G only till
the
row where the cell value in column F is "Production" what would
be
the
syntax?

something like While Not Cells(row, 6).Value = "Production"






  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default loop

Don,

Thanks. As many times as I have referred to help on this topic, I have
overlooked this one critical sentence in the remarks (...To avoid
problems, set these arguments explicitly each time you use this
method.)

Alan

Don Guillett wrote:
easy to find in the vba help index for FIND or FINDNEXT

--
Don Guillett
SalesAid Software

"acampbell" wrote in message
ups.com...
Tom,

I read your response and looked in to other posts in which "persistent
values" may have contributed to errors in results or routines. Below
is a snippet of a response you provided in another thread. Would it be
good practice to employ this suggestion in any find operation?

...After looking at your code, I would suggest you provide all
arguments to the find function. Several of the arguments have
persistent
values and could be causing the find operation to fail mysteriously...

Thanks.

Alan




Tom Ogilvy wrote:
Any advice on more efficient/effective coding is always welcome.

Directly trying to use the results of a method that could result in an
error
as done in the example would be a poor approach. Even if you are sure
the
sought value is present, failure to account for persistent values of
arguments to that method could again result in an error or inconsistent
results.

--
Regards,
Tom Ogilvy


"acampbell" wrote in message
oups.com...
Another good point. I am much more a student than a teacher out here.
Any advice on more efficient/effective coding is always welcome.

Thanks.

Alan

Don Guillett wrote:
or. But,why select???

Sub findit1()
'On Error Resume Next 'uncomment if you don't want error if not found
Cells(Range("f7:f100").Find("Production").Row + 1, "F").Select
End Sub


--
Don Guillett
SalesAid Software

"acampbell" wrote in message
ups.com...
Don,

Good point. This uses find instead.


Dim MyRange As Range
Dim MyFind
Set MyRange = Range("F7:F100") ' adjust as needed
Set MyFind = MyRange.Find(What:="Production", LookIn:=xlValues)
If Not MyFind Is Nothing Then
Range(MyFind.Address).Offset(0, 1).Select
Exit Sub
End If
End Sub



Don Guillett wrote:
Looping will be slower than FIND. Look in the vba help. If more
than
one
then use FINDNEXT.

--
Don Guillett
SalesAid Software

wrote in message
oups.com...
Somewhere in column F i have the value "Production". It could be
in
F100 or F157. It is not known.
My cursor is in cell G7. I am using activecell.offset(1,0).select
to
scroll downwards. I want to move my cursor in column G only till
the
row where the cell value in column F is "Production" what would
be
the
syntax?

something like While Not Cells(row, 6).Value = "Production"





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
For Each ... Next loop - need to reference the loop variable [email protected] Excel Programming 4 July 13th 06 06:12 PM
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Loop Function unable to loop Junior728 Excel Programming 1 July 28th 05 10:23 AM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


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