View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Charlie[_13_] Charlie[_13_] is offline
external usenet poster
 
Posts: 1
Default Drop-down in FIND dialog


Hi,

Here the code.

You can do the dropdown by putting a Validation on a cell.
Select a cell (in this code I use "K1")
Menu: Data-Validation
Allow: "List"
Source: Select your range (AuditIDs)

Then here the code:
The code assume your dropdown(validation cell) is K1

Sub FindMyCell()
Dim myCell As Range
Dim StrID As String

StrID = Range("K1")

Columns("D:D").Select
Set myCell = Selection.Find(What:=StrID, After:=ActiveCell,
LookIn:=xlValues, LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False)

If Not myCell Is Nothing Then
myCell.Offset(0, 3).Select
If Len(myCell.Offset(0, 3)) = 0 Then
Set myCell = ActiveCell.Offset(2, 0)
Else: Set myCell = ActiveCell
End If
myCell.Activate
Else
MsgBox "No Match."
End If
End Sub

Charlie
'Opener Consulting Home' (http://www.openerconsulting.com)


MikeF;175971 Wrote:
Have some code - as below - that looks up the first occurence of a
specific
string in Column D, then acts on it.

hat I'm more than desperate for is a drop-down that enables me to
CHOOSE
which string to find in the line Cells.Find(What:="-02"

The drop-down list is "-01" / "-02" / "-03" / and so on, anywhere up
to
"-99", and comes from the range "AuditIDs".

It can be a UserForm, or even the Find dialog box [must be the one
that
comes up with CTRL-F, as xlDialogFormulaFind.show does not work], or
even an
InputBox, as long as whatever value I choose, or even type, fills in
the
What:= in the following code.

Have tried a lot of different things, and am stumped.

Disregard the rest of the sub, it's working perfectly, other than of
course,
the objective herein re a drop-down for Cells.Find(What:=

Thanx sincerely in advance.
Regards,
- Mike


Sub FindMyCell()

Dim myCell As Range

Range("D7").Select
Cells.Find(What:="-02", After:=ActiveCell, LookIn:=xlValues, LookAt:=
_
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Set myCell = ActiveCell
If Len(myCell.Offset(0, 3)) = 0 Then
Set myCell = ActiveCell.Offset(2, 0)
Else: Set myCell = ActiveCell
End If

myCell.Activate
End Sub



--
Charlie
------------------------------------------------------------------------
Charlie's Profile: http://www.thecodecage.com/forumz/member.php?userid=89
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=48685