Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Determine what row is currently selected

The code below doesn't produce errors. I changed Me.txt_GoToTask becasue it
wasn't ddefined on my pc.
Sub cmd_GotoTask_Click()

Dim C As Range
Dim mycolumns As Range

With Sheets("sheet1")

'Execute the find
Set mycolumns = Columns("A:A")

'Search the Task# column for the entered value
Set C = mycolumns.Find(What:="abc", _
After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not C Is Nothing Then
intRowPointer = C.Row
Call FillControls
Else
MsgBox "Task not found"
End If

End With

End Sub


"Dale Fye" wrote:

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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 169
Default Determine what row is currently selected

Joel,

The problem was with the After:= parameter, since I didn't have an active
cell in that sheet, it was causing a problem, when I changed that to
".Cells(1,1)" it worked perfectly.

Thanks

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


"Joel" wrote:

The code below doesn't produce errors. I changed Me.txt_GoToTask becasue it
wasn't ddefined on my pc.
Sub cmd_GotoTask_Click()

Dim C As Range
Dim mycolumns As Range

With Sheets("sheet1")

'Execute the find
Set mycolumns = Columns("A:A")

'Search the Task# column for the entered value
Set C = mycolumns.Find(What:="abc", _
After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not C Is Nothing Then
intRowPointer = C.Row
Call FillControls
Else
MsgBox "Task not found"
End If

End With

End Sub


"Dale Fye" wrote:

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.

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
determine the name of the selected pivot table Tim879 Excel Discussion (Misc queries) 1 September 23rd 07 05:02 PM
Determine what row is currently selected Dale Fye Excel Programming 0 August 17th 07 01:59 AM
Determine if entire row or column is selected MC82 Excel Programming 3 April 29th 06 12:33 AM
Determine which button was selected ?? dcarr Excel Programming 4 October 27th 04 11:02 PM
Determine Selected Cells John Tripp[_2_] Excel Programming 2 July 31st 03 02:48 PM


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