Drop-down in FIND dialog
OssieMac,
Thanx for the reply, both to you and Charlie who also proposed a similiar
solution.
Contrary to what I just sent to Charlie, your solution[s] do work.
I just wasn't prepared to pre-set the audit number prior to initiating the
sub, but again --- that does work, and certainly will suffice.
But ideally, the drop-down box would appear/pop-up *as the code is running*,
specifically upon hitting the "Cells.Find(What:" line, thereby enabling
the user to choose the AuditID "on the fly".
Can this be accomplished?
Regards,
- Mike
"OssieMac" wrote:
Hi Mike,
I am assuming that AudiIds is a named range. If so then create a dropdown
list from it.
Select any vacant cell
Select Data - Validation
On the Settings tab in Allow field select List
In the Source field insert =AuditIDs (Equal sign essential)
Click OK.
Now each time you select that cell the drop down arrow will appear and you
can select a value.
Change your code as follows. I have used Sheet1 cell A1 for the drop down.
Edit this to suit your worksheet.
Your find code will produce an error if it does not find the target. Of
course if you know that it will always find the target then this might not
course you a problem but if you want some help improving this then let me
know.
Also it is possible to force the code to execute each time you make a
selection from the dropdown so if you want that then let me know.
The following is the code to incorporate the dropdown result into your code.
Sub FindMyCell()
Dim myCell As Range
Dim strTofind As String
strTofind = Sheets("Sheet1").Range("A1")
Range("D7").Select
Cells.Find(What:=strTofind, 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
--
Regards,
OssieMac
|