Change a cell by clicking on it using VB
Closed
Hello,
I would like to be able to change a cell's color to blue by clicking on it with the cursor using visual basic. For instance, I have 30 cells numbered 1 to 30. I want to be able to choose #4 and have it change its color automatically, but not lose the number "4" that's in the cell. How can I accomplish this please?
I would like to be able to change a cell's color to blue by clicking on it with the cursor using visual basic. For instance, I have 30 cells numbered 1 to 30. I want to be able to choose #4 and have it change its color automatically, but not lose the number "4" that's in the cell. How can I accomplish this please?
Related:
- Change a cell by clicking on it using VB
- Mouse not clicking where pointer is - Guide
- Why is my mouse clicking on its own - Guide
- Change computer name cmd - Guide
- Change lg tv name - Guide
- Idm language change - Guide
1 response
suppose the data are in column A
try this macro
try this macro
Sub test() Dim j As Range, k As Integer, m As Integer Dim x, cfind As Range, add As String On Error Resume Next Columns("A:A").Interior.ColorIndex = xlNone x = InputBox("type the number you want e.g 4") Range("a1").Select Set j = Columns("a:a").Cells.Find(what:=x, lookat:=xlWhole) If j Is Nothing Then MsgBox "the value " & x & " not available " GoTo line1 End If add = j.Address j.Interior.ColorIndex = 3 Do Set j = Cells.FindNext(j) If j Is Nothing Then GoTo line1 If j.Address = add Then GoTo line1 j.Interior.ColorIndex = 3 Loop line1: End Sub