[RESOLVED] [Excel VBA] Open popup form by clicking on a cell
Hello everyone! I found this function that allows to open a popup window by clicking on a particular cell:
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Address = "$A$3" Then
Cancel = True
MsgBox "Here is your code!"
End If
End Sub
What I want to do is integrate this function in my code: in practice, the following Sub conducts a search for a word on a range of cells and, if found, make the cell red. It should also enable the opening of a form (newarticle) in the VBAProject.
Code:
Sub CheckRecords()
...
With Sheets(1).Range("B6:B100")
'search the word in the stringa variable in the range B6:B100
Set Rng = .Find(What:=stringa, _
After:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
'If it find the word colors of red cell and enables opening form
If Not Rng Is Nothing Then
Rng.Interior.ColorIndex = 3
'Rng.Address returns the absolute address of the cell (ex: $B$9)
???how to enable form???
End If
End With
...
End Sub
My question is: how to enable the opening of the form (newarticle) by clicking on the cells marked by the search?
I hope I have clearly explained the problem ... and thanks in advance to all!
Re: [Excel VBA] Open popup form by clicking on a cell
Quote:
???how to enable form???
userform1.show
change name of userform to suit, userform must be in same workbook as code
Re: [Excel VBA] Open popup form by clicking on a cell
[SOLVED] Put this code outside the Sub... Thanks! :)
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Interior.ColorIndex = 3 Then
Cancel = True
newarticle.Show
End If
End Sub