Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default VBA - JumpTo Specific Row

Proposed:
A double click in a cell launches an input box.
If what is entered exists in any row in Col X then
immediatly show the Sheet starting at that row?

Is that possible?

Thanks - Kirk
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default VBA - JumpTo Specific Row

Hi,

Right click on the worksheet tab name and select View code and paste the
following into the VBA editor window.

As per the comment, try with and without the Cancel=True line to see what
you think is the best.


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

'Try with and without Cancel = True
Cancel = True

'Place cell in top row of window.
ActiveWindow.ScrollRow = Target.Row

'Alternative option to place cell in top left of window
'Application.Goto Range(Target.Address), Scroll:=True

End Sub

Regards,

OssieMac


"kirkm" wrote:

Proposed:
A double click in a cell launches an input box.
If what is entered exists in any row in Col X then
immediatly show the Sheet starting at that row?

Is that possible?

Thanks - Kirk

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default VBA - JumpTo Specific Row

My apologies. I did not answer you question properly. Here is the completed
code. Right click on the sheet name tab and select View Code and copy and
paste the macro into the VBA editor.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Dim response As Variant
Dim foundCell As Range

Cancel = True

response = InputBox("Enter data to find in column")

Columns(Target.Column).Select

Set foundCell = Selection.Find(What:=response, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)

If Not foundCell Is Nothing Then

foundCell.Select
'Place cell in top row of window.
ActiveWindow.ScrollRow = foundCell.Row

'Alternative: Place cell in top left of window
'Application.Goto Range(foundCell.Address), Scroll:=True

Else
MsgBox response & " Not found"
Target.Select
End If

End Sub

Regards,

OssieMac


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default VBA - JumpTo Specific Row

Many thanks OssieMac

I have it working !!

Is it possible to make 2 changes ?

1. Execute the code from a module, so I can call it from more than one
sheet without duplicating it?
2. The eventual cell that is displayed and selected - can the bold
outline around the cell be off?

Thanks - Kirk
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default VBA - JumpTo Specific Row

Hi Kirk,

Selected Cells always have a bold outline. I don't know any way of getting
rid of it.

For you other request insert the following private sub in each worksheet so
that it calls a sub in a module. (Being an event driven procedure it must be
tied to the worksheet):-

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)

Cancel = True
Call Cell_Select(Target)

End Sub


Then insert the following sub in a module so that it can be called from the
event driven procedure in each worksheet. The Target value is passed to it
when it is called:-

Sub Cell_Select(Target)

Dim response As Variant
Dim foundCell As Range

response = InputBox("Enter data to find in column")

Columns(Target.Column).Select

Set foundCell = Selection.Find(What:=response, _
After:=Cells(Rows.Count, Target.Column), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)

If Not foundCell Is Nothing Then

foundCell.Select
'Place cell in top row of window.
ActiveWindow.ScrollRow = foundCell.Row

'Alternative: Place cell in top left of window
'Application.Goto Range(foundCell.Address), Scroll:=True

Else
MsgBox response & " Not found"
Target.Select
End If

End Sub


I will be out of the picture for a few days but will check back here after
that in case you have any further problems but feel free to post a fresh
request if you want answers before I return.

Regards,

OssieMac




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default VBA - JumpTo Specific Row

Hi OssieMac,

That's all working perfectly.

I've now been able to add the rest of the code and can
see a need for one last capability! I can't see how it knows
which Sheet it's using. I assume its the one that calls it.

However there's 3 sheets involved and sometimes you want one of the
others (instead of the one you clicked in).

Is that a problem?

Thanks again,
Cheers - kirk
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default VBA - JumpTo Specific Row

Hi Kirk,

I have been away for a couple of days and hence the delayed reply. Your
assumption of how Excel knows which sheet is correct. It is the one that it
is called from.

Re your other question: It is possible to search other sheets but first a
couple of questions.

Is my assumption correct that you only want to search the same column in
each worksheet?
You said there is 3 sheets. Is that the total number of sheets in the
workbook or did you mean there are 3 sheet to search. If the latter, then
what are the worksheet names to be searched?

I have been assuming that there will always be only one value to match the
one entered. Is this correct or is it possible for there to be more than one
cell containing the value being searched? (Either in a single worksheet or in
all 3 worksheets).

If the answer to the previous question is 'yes', then does it matter which
value is found and if so, what rules should be applied such as after the cell
that was clicked, the first occurrence in the workbook etc and also does it
matter what order the worksheets are searched? That is the one that was
clicked first and then the other 2 worksheets in any order or a priority
order.

Regards,

OssieMac

"kirkm" wrote:

Hi OssieMac,

That's all working perfectly.

I've now been able to add the rest of the code and can
see a need for one last capability! I can't see how it knows
which Sheet it's using. I assume its the one that calls it.

However there's 3 sheets involved and sometimes you want one of the
others (instead of the one you clicked in).

Is that a problem?

Thanks again,
Cheers - kirk

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
Send data from userform to specific cell on specific sheet? JennLee Excel Programming 10 March 10th 07 02:55 AM
Link from a specific Cell in Excel to a specific para. in Word CathyK Excel Worksheet Functions 0 August 10th 06 04:40 PM
Form a circle (ie. color specific cells) given specific radius David Excel Programming 5 April 11th 06 03:56 PM
Highlight a row if a specific cell is specific numbers/words sea0221 Excel Worksheet Functions 2 March 9th 05 12:06 AM
How do I make a cell date specific to input a value on a specific. ebuzz13 Excel Discussion (Misc queries) 1 January 18th 05 05:53 PM


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