Thread: Query
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
MaC MaC is offline
external usenet poster
 
Posts: 4
Default Query

I suppose sample of my code can be helpful:

Sub FindInWorkbook(ColA_WantedValue As Long)
'Sample code - Mario C. (MaC)
'use it free everywhere
'this subroutine seeks wanted value in all worksheets of your workbook

Dim Wst As Worksheet
Dim ColA_Counter As Long

For Each Wst In ThisWorkbook.Worksheets
For ColA_Counter = 2 To Wst.Range("A65536").End(xlUp).Row
If Wst.Range("A" & ColA_Counter).Value = ColA_WantedValue Then
MsgBox "Wanted value (" & ColA_WantedValue & ") exists in
worksheet " & Wst.Name
Wst.Activate
Exit Sub
End If
Next
Next

End Sub

Sub AskUserAndFind()
'now we can call above sub with user prompt as a argument
Call FindInWorkbook(InputBox("What is the wanted value in column A?"))
End Sub

Good luck
Mario C (MaC)

Użytkownik "JN" napisał w wiadomości
...
Is there any way to accomplish the following?

I have a workbook containing multiple worksheets. Col A in all worksheets
contains a series of numbers that are unique:

Wksht 1 Wksht 2
Col A Col A
126345 995346
678910 798394

How can I get Excel to prompt the user for a # in Col A and, based on a
match, open JUST that worksheet.

Thanks for any/all help!