RE: Determine what row is currently selected



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: error messages practically worthless
    ... the .open statement) it opens fine. ... Access itself makes the query statement. ... Dim cnnFLDCW, cnnCurPrj As ADODB.Connection ... > ways to get this error message, such as typographical errors, incorrect ...
    (microsoft.public.access.externaldata)
  • Re: Return to form if query unmatched
    ... I am getting the following error message: ... If it doesn't pop up a message and set Cancel = True. ... Dim Myrst As Recordset ... Dim MyRecCount As Long ...
    (microsoft.public.access.queries)
  • Re: Script to create subdirectories
    ... I tried it and I'm getting an error message at this line: ... Dim aFolders, newFolder ... ' Splits the various components of the folder name. ...
    (microsoft.public.windows.server.scripting)
  • RE: ODBC Driver Login Failed
    ... Further coding has revealed that this error message does not occur if I do ... Dim oCnn As ADODB.Connection ... Set oCnn = New ADODB.Connection ... 'Clean up Excel Objects ...
    (microsoft.public.access.modulesdaovba)
  • RE: Determine what row is currently selected
    ... Please reply to newsgroup only. ... Sub cmd_GotoTask_Click ... Dim mycolumns As Range ... intRowPointer = C.Row ...
    (microsoft.public.excel.programming)