Using worksheet_selectionchange()

payners

New Member
Joined
Dec 17, 2018
Messages
2
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">All,

I'm not sure why my code is not working exactly as expected. Only when the first cell is selected, a message box should popup with instructions on how to change the date/time. I would like to click on a cell that is linked to DTPicker1, change the date/time then click the cell again to enter.
What happens on first cell select, the message does pop up and I am able to change the date/time. What doesn't happen is that once the cell is selected, I am am to change the date/time but when I click back on the cell to enter nothing happens until the cell below is selected and it is not in the correct format. I have to make changes on the new cell then come back to select the original cell in order for the changes to be inputed. Also The randomize routines key running on every slection change. Any help would be greatly appreciated!!!;);)
Private
Sub DTPicker1_CallbackKeyDown(ByVal KeyCode as Integer, ByVal Shift
as Integer, ByVal Callbackfield as String, ByVal CallbackDate as Date)

End Sub

Private Sub Worksheet_Selectionchange(ByVal Target as Range)
If not Intersect(Target, Range("a3")) is nothing then
Msgbox
(“To change the date/time, Select the number and use the arrows.”)
End if
With Sheet1.DTPicker1
.Height = 20
.Width = 125
.Format = dtpCustom
.CustomFormat = "ddHHmmZMMMyy"
If Not intersect(Target, Range("a3:a502")) is nothing then
.Visible = True
.Top = Target.Top
.Left = Target.offset(0,1).left
.Linkedcell = Target.address
Me.Range(DTPicker1.LinkedCell)= Format(DTPicker1.value,Me.Range("a3").NumberFormat)
Else
.Visible = False
End If
End With
If not intersect(Target, Range("b3:b502")) is nothing then
Randomize
Target
.value=StaticRand()
End if
If not intersect(Target, Range("c3:c502")) is nothing then
Randomize
Target
.Value = Int((6-1+1)* StaticRand+1)
If Range("b3").value < 0.25 then
Target
.value =target.value & "NO COVERAGE"
End if</code>
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,215,297
Messages
6,124,107
Members
449,142
Latest member
championbowler

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