RE: Determine what row is currently selected

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Joel,

Appreciate your help and sticking with me on this.

Here is my code. I'm getting an "Object required (424) error generated on
the row that starts Set C =

Private Sub cmd_GotoTask_Click()

Dim C As Range

With Sheets("sheet1")

'Execute the find
Columns("A:A").Select

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

'Search the Task# column for the entered value
Set C = 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 = C.Row
Call FillControls
Else
Debug.Print Err.Number, Err.Description
MsgBox "Task not found"
End If
Err.Clear
On Error GoTo 0

End With

End Sub

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


"Joel" wrote:

Dim c As Range

"Dale Fye" wrote:

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.
.



Relevant Pages

  • Re: Problem with inserting page numbers
    ... The error message does not display the entire path and does not display on ... Selecting this optionOpens a dual window ... This reply is posted in the Newsgroup; please post any follow question or reply ...
    (microsoft.public.word.docmanagement)
  • Re: Displays only few sites
    ... SSL Secured Web Sites by Using Internet Explorer in Windows XP ... Can't display page or "Internet Explorer could not ... "The Page Cannot Be Displayed" Error Message on a Secure Web Site ... Replies are posted only to the newsgroup for the benefit or other readers. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: WU Error
    ... WINUP: Error Message: Cannot Display Page ... Please tell the newsgroup how any ... > mos ago. ...
    (microsoft.public.windowsupdate)
  • RE: Lsass.exe - when trying to update a password.
    ... Shortly before this error message, i lost all use of network ... > Thank you for posting to the SBS Newsgroup. ... What exact password you trying to update? ... > Microsoft CSS Online Newsgroup Support ...
    (microsoft.public.windows.server.sbs)
  • Re: Exchange not creating users
    ... Base research on your error message, I suggest we try the following steps: ... Please install latest updates and service packs on your Exchange ... Microsoft CSS Online Newsgroup Support ... This newsgroup only focuses on SBS technical issues. ...
    (microsoft.public.windows.server.sbs)