Retrieve date from MsgBox to TextBox in other Form

Oscar VM

New Member
Joined
Feb 28, 2019
Messages
1
Hello, I got stuck on the following code that shows date selected from datepicker
Private Sub select_label(msForm_C As MSForms.Control)
'/* Capture the selected date */
Dim i As Integer, sel_date As Date
i = Split(msForm_C.Name, "_")(1) - 1
sel_date = FirstCalSun(curMonth) + i


'/* Transfer the date where you want it to go */
MsgBox sel_date
End Sub

this datepicker is in UserForm2, I algo have one TextBox in UserForm1 with the following code

Private Sub TextBox1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
SelectDate.Show


End Sub


I need to send data from sel_date to TextBox1 located on UserForm1
how can I do that?
appreciate your help
Oscar VM
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
14,789
Office Version
  1. 2010
Platform
  1. Windows
Try this

Code:
[COLOR=#333333]Private Sub select_label(msForm_C As MSForms.Control)[/COLOR]
[COLOR=#333333]'/* Capture the selected date */[/COLOR]
[COLOR=#333333]Dim i As Integer, sel_date As Date[/COLOR]
[COLOR=#333333]i = Split(msForm_C.Name, "_")(1) - 1[/COLOR]
[COLOR=#333333]sel_date = FirstCalSun(curMonth) + i[/COLOR]

[COLOR=#0000ff]if sel_date <> "" then
      userform1.textbox1.value = sel_date
end if[/COLOR]

[COLOR=#333333]'/* Transfer the date where you want it to go */[/COLOR]
[COLOR=#333333]MsgBox sel_date[/COLOR]
[COLOR=#333333]End Sub[/COLOR]
 
Last edited:
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,017
Messages
5,834,960
Members
430,330
Latest member
drAli77

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
Top