Worksheet_SelectionChange

Kathleen_0422

Board Regular
Joined
May 5, 2011
Messages
64
I am using a worksheet event which will display and image when all required fields have entry:

It appears that the only way to fire the macro is when the user takes focus off the last cell. Is there a way I can have the image display even if the user is on the cell or a cell has been selected in the range as shown

<code>

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If ActiveSheet.Range("F7").Value <> "" And ActiveSheet.Range("F9").Value <> "" And ActiveSheet.Range("F11").Value <> "" And ActiveSheet.Range("F13").Value <> "" And ActiveSheet.Range("F15").Value <> "" And ActiveSheet.Range("F17").Value <> "" And ActiveSheet.Range("F19").Value <> "" And ActiveSheet.Range("F21").Value <> "" Then
Image1.Visible = True
Else
Image1.Visible = False
End If

End Sub

</code>
Column F has validation criteria
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi Kathleen,

The code below will fire whenever your selection includes one of the cells
in your required range.

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    On Error GoTo CleanUp
    Dim rngReqd As Range
    Set rngReqd = Range("F7,F9,F11,F13, F15, F17, F19, F21")
    If Intersect(rngReqd, Target) Is Nothing Then GoTo CleanUp
 
    Application.EnableEvents = False
 
    If Application.CountA(rngReqd) = rngReqd.Cells.Count Then
        Image1.Visible = True
    Else
        Image1.Visible = False
    End If
CleanUp:
    Application.EnableEvents = True
    Set rngReqd = Nothing
End Sub

Is there a way I can have the image display even if the user is on the cell or a cell has been selected in the range as shown

Not sure that I follow what you mean by "is on the cell"... do you mean if they change the value of one of the cells without moving to another cell?

If that is what your looking for, then Worksheet_Change would be a better event to use than Worksheet_SelectionChange. You can adapt the code above.
 
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,152
Members
452,891
Latest member
JUSTOUTOFMYREACH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top