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
 

Some videos you may like

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

DanteAmor

Well-known Member
Joined
Dec 3, 2018
Messages
12,593
Office Version
  1. 2007
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:

Watch MrExcel Video

Forum statistics

Threads
1,108,993
Messages
5,526,118
Members
409,685
Latest member
Bellybb

This Week's Hot Topics

Top