Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

Please help with the vba code

0
Please help with the vba code to find the number in the area (L8:P17) that matches 1 of the 4 numbers in the area (F1:I1) and automatically flash through the 4 corresponding buttons, thank you.
Answer
Discuss

Answers

0
Selected Answer
Thank you very much, can you help me add VBA code to delete the found numbers?
Discuss

Discussion

Hi HGVIET,

A couple of things before I discuss your latest question.
1) You should change the title of your post to something more meaningful such as: Need code to search a range of cells for a specific number.
2) Do not use the "Answer" portion to post a question. After clicking on "Ask Quetion" post your question in the "Body" area.

As for your latest question (delete found numbers) that should have been included in your original post. You can't keep adding additional conditions - include it/them in the original question or make a new post.

As for deleting the numbers, which numbers do you want deleted - range "F1:I1" or the found number in range "L8:P17"?
WillieD24 (rep: 637) Oct 19, '24 at 11:32 am
HGVIET,

I don't know how you did it but you selected your own post as the preferred answer instead of mine.
And you haven't fixed the title of your post as I recommended.
You also haven't answered my question (above) about which number(s) to delete.
WillieD24 (rep: 637) Oct 20, '24 at 12:49 am
Add to Discussion
0

 Hello HGVIET,

Your code is close - just needs a tweak.

In your code you specify where to run the code ( "L10" ). Rather than specify where to look, you want code to find the value in "F1" in the range "L8:P17" and then run your code on that cell. A simple version of this is:

Sub Find_F1_Number()

Dim i As Long
Dim where As String

Const t = 1     ' 1s
Const freq = 5

where = Range("L8:P17").Find(Range("F1").Value).Address
With Range(where)
    Do
        i = i + 1
        Application.Wait Now + TimeSerial(0, 0, t)
        .NumberFormat = ";;;" ' set o A1 to invisible
        Application.Wait Now + TimeSerial(0, 0, t)
        .NumberFormat = "General" ' set o A1 to visible
        If i >= freq And .NumberFormat = "General" Then Exit Sub
    Loop
End With

End Sub
'

I then copied this code 3 times and changed "F1" to "G1", "H1", and "I1"

In the attached file I have assigned these macros to your buttons "A", "B", "C", & "D".

Hope this helps, if so please remember to mark my answer as Selected.

Cheers   :-)

Discuss


Answer the Question

You must create an account to use the forum. Create an Account or Login