View Single Post
 
Old 10-19-2025, 11:26 AM
roger.stern@mail.com roger.stern@mail.com is offline Windows 10 Office 2021
Novice
 
Join Date: Sep 2023
Posts: 20
roger.stern@mail.com is on a distinguished road
Default Getting VBA Macro to work with a range of cells

I've created a macro to launch the mini date picker when I click on cell A1.
It works.

When I change the range to ("A1:A10") it doesn't work at all. how can I launch the date picker when I click in any cell in a range?


Quote:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' Set the specific cell you want to monitor
Dim MonitoredCell As Range
Set MonitoredCell = Me.Range("A1")

' Check if the newly selected cell is the monitored cell and it's a single cell
If Target.Address = MonitoredCell.Address And Target.Count = 1 Then
ActiveSheet.Shapes("Calendar").Visible = True
ActiveSheet.Shapes("Calendar").Left = ActiveCell.Left + ActiveCell.Width
ActiveSheet.Shapes("Calendar").Top = ActiveCell.Top + ActiveCell.Height


Else

' hide the calendar if a cell is selected outside the Start or Completion Date columns
ActiveSheet.Shapes("Calendar").Visible = False


End If
End Sub
Attached Files
File Type: xlsm Working Test except for range.xlsm (23.0 KB, 1 views)
Reply With Quote