PC Review


Reply
Thread Tools Rate Thread

Determine what row is currently selected

 
 
=?Utf-8?B?RGFsZSBGeWU=?=
Guest
Posts: n/a
 
      17th Aug 2007
I have implemented the Selection.Find method to find a value in a column, and
have the code working to display an error message if the value was not found,
but cannot figure out how to determine the row of the cell that is selected
if a match is found. The line of code that reads intRowPointer =
Selection.Row always returns a 1. Any help would be greatly appreciated.

'Turn off error trapping for in-line analysis
On Error Resume Next

'Search the Task# column for the entered value
Selection.Find(What:=Me.txt_GoToTask, After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
'If the task number was found, move the pointer to it.
'If not, display an error message
If Err.Number = 0 Then
intRowPointer = Selection.Row
Call FillControls
Else
MsgBox "Task not found"
End If
Err.Clear
On Error GoTo 0

Dale
--
Email address is not valid.
Please reply to newsgroup only.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?RGFsZSBGeWU=?=
Guest
Posts: n/a
 
      17th Aug 2007
Joel,

When I tried that, I get a variable not defined error.

When I try to Dim the variable C, what should I declare it as?

--
Email address is not valid.
Please reply to newsgroup only.


"Joel" wrote:

> You didn't add a set.
>
> set c = Selection.Find(What:=Me.txt_GoToTask, After:=ActiveCell, _
> lookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
> SearchDirection:=xlNext, _
> MatchCase:=False, SearchFormat:=False).Activate
>
> Now you can find the row by using c.row
>
> "Dale Fye" wrote:
>
> > I have implemented the Selection.Find method to find a value in a column, and
> > have the code working to display an error message if the value was not found,
> > but cannot figure out how to determine the row of the cell that is selected
> > if a match is found. The line of code that reads intRowPointer =
> > Selection.Row always returns a 1. Any help would be greatly appreciated.
> >
> > 'Turn off error trapping for in-line analysis
> > On Error Resume Next
> >
> > 'Search the Task# column for the entered value
> > Selection.Find(What:=Me.txt_GoToTask, After:=ActiveCell,
> > LookIn:=xlFormulas, _
> > LookAt:=xlPart, SearchOrder:=xlByRows,
> > SearchDirection:=xlNext, _
> > MatchCase:=False, SearchFormat:=False).Activate
> > 'If the task number was found, move the pointer to it.
> > 'If not, display an error message
> > If Err.Number = 0 Then
> > intRowPointer = Selection.Row
> > Call FillControls
> > Else
> > MsgBox "Task not found"
> > End If
> > Err.Clear
> > On Error GoTo 0
> >
> > Dale
> > --
> > Email address is not valid.
> > Please reply to newsgroup only.

 
Reply With Quote
 
=?Utf-8?B?Sm9lbA==?=
Guest
Posts: n/a
 
      17th Aug 2007
You didn't add a set.

set c = Selection.Find(What:=Me.txt_GoToTask, After:=ActiveCell, _
lookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

Now you can find the row by using c.row

"Dale Fye" wrote:

> I have implemented the Selection.Find method to find a value in a column, and
> have the code working to display an error message if the value was not found,
> but cannot figure out how to determine the row of the cell that is selected
> if a match is found. The line of code that reads intRowPointer =
> Selection.Row always returns a 1. Any help would be greatly appreciated.
>
> 'Turn off error trapping for in-line analysis
> On Error Resume Next
>
> 'Search the Task# column for the entered value
> Selection.Find(What:=Me.txt_GoToTask, After:=ActiveCell,
> LookIn:=xlFormulas, _
> LookAt:=xlPart, SearchOrder:=xlByRows,
> SearchDirection:=xlNext, _
> MatchCase:=False, SearchFormat:=False).Activate
> 'If the task number was found, move the pointer to it.
> 'If not, display an error message
> If Err.Number = 0 Then
> intRowPointer = Selection.Row
> Call FillControls
> Else
> MsgBox "Task not found"
> End If
> Err.Clear
> On Error GoTo 0
>
> Dale
> --
> Email address is not valid.
> Please reply to newsgroup only.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Determine currently selected control Gaetan Microsoft Access 6 23rd Nov 2007 05:13 PM
RE: Determine what row is currently selected =?Utf-8?B?Sm9lbA==?= Microsoft Excel Programming 2 17th Aug 2007 02:06 AM
RE: Determine what row is currently selected =?Utf-8?B?RGFsZSBGeWU=?= Microsoft Excel Programming 0 17th Aug 2007 01:59 AM
Determine the currently selected field & row Terry Hornsby Microsoft Access Queries 6 24th Dec 2003 05:12 PM
Determine Selected Cells John Tripp Microsoft Excel Programming 2 31st Jul 2003 02:48 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:46 AM.