Combining Code each works separately, but trying to combine.

skeeeter56

New Member
Joined
Nov 26, 2016
Messages
42
Office Version
  1. 2019
Platform
  1. Windows
I am designing a sheet which has a table on a sheet, it has a number of columns, 2 of which are for inputting dates.

I am trying to get it so that when you click cell pop calendar appears select date and this in placed into cell.

I can get it to work with the below code for each column, but I am trying to combine so that when either cell in either column is clicked the calendar pops up and inserts date in cell clicked.

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    'If Not Intersect(Target, Me.ListObjects("March22").ListColumns(1).DataBodyRange) Is Nothing Then
      
        'Call Calendar.SelectedDate(ActiveCell)
    If Not Intersect(Target, Me.ListObjects("March22").ListColumns(6).DataBodyRange) Is Nothing Then
        Call Calendar.SelectedDate(ActiveCell)
    End If

End Sub
I hope this is possible
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
@skeeeter56 Not tested but try like

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
 If Target.Count < 1 Then Exit Sub
    If Not Intersect(Target, Me.ListObjects("March22").ListColumns(1).DataBodyRange) Is Nothing _
    Or Not Intersect(Target, Me.ListObjects("March22").ListColumns(6).DataBodyRange) Is Nothing Then _
    
        Call Calendar.SelectedDate(Target)
    End If

End Sub
 
Upvote 0
Solution
Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Count < 1 Then Exit Sub If Not Intersect(Target, Me.ListObjects("March22").ListColumns(1).DataBodyRange) Is Nothing _ Or Not Intersect(Target, Me.ListObjects("March22").ListColumns(6).DataBodyRange) Is Nothing Then _ Call Calendar.SelectedDate(Target) End If End Sub
That did the trick thanks so much.
 
Upvote 0

Forum statistics

Threads
1,215,452
Messages
6,124,914
Members
449,195
Latest member
Stevenciu

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