Que tal Greg,
Perdona la tardanza. Creo que es la segunda opción. Tengo un control de calendario y pongo el valor por medio de VBA. La forma es más o menos la siguiente. Funciona seleccionando una fecha y después aprieto ACEPTAR.
Libro1 |
---|
|
---|
| C | D | E | F | G | H | I |
---|
8 | Septiembre | | | | | | |
---|
9 | Dom | Lun | Mar | Mi | Jue | Vie | Sb |
---|
10 | 28 | 29 | 30 | 31 | 1 | 2 | 3 |
---|
11 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
---|
12 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
---|
13 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
---|
14 | 25 | 26 | 27 | 28 | 29 | 30 | 31 |
---|
15 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
---|
16 | | | | | | | |
---|
17 | | ACEPTAR | | CANCELAR | | | |
---|
|
---|
Como introduzco una fecha anterior y otra posterior, lo ideal sería que validara que la fecha posterior. El código (que no es mío) te lo anexo:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>SAR - Seguimento de Asuntos - V2.0_UserForm2.htm</title><style type=text/css><!--
body {background-color: #ffffff; color: #000000; font-family: "Courier New"; font-size: 10pt}
.keyword {background-color: #ffffff; color: #000080}
.comment {background-color: #ffffff; color: #008000}
--></style></head><body><nobr><div></div><div></div><div><span class="keyword">Option Explicit</span></div><div><span class="keyword">Dim</span> dDate<span class="keyword">As Date</span></div><hr size="1"><div></div><div><span class="keyword">Private Sub</span> Calendar1_Click()</div><div></div><div><span class="keyword">End Sub</span></div><hr size="1"><div></div><div><span class="keyword">Private Sub</span> CommandButton1_Click()</div><div>Calendar1 = Date</div><div>SpinButton1 = 0</div><div>SpinButton2 = 0</div><div>SpinButton3 = 0</div><div><span class="keyword">End Sub</span></div><hr size="1"><div></div><div><span class="keyword">Private Sub</span> CommandButton2_Click()</div><div><span class="comment">'Place the date from the calendar into the active cell</span></div><div><span class="keyword">Dim</span> cancel<span class="keyword">As Integer</span></div><div></div><div> ActiveCell.Value = Calendar1.Value</div><div></div><div><span class="comment">'Prueba de validación de fechas</span></div><div></div><div><span class="keyword">If</span> ActiveCell.Value< [G11]<span class="keyword">Then</span> cancel =<span class="keyword">True</span></div><div></div><div></div><div><span class="comment">'Prueba de validación de fechas</span></div><div><span class="comment">'Dismiss the userform</span></div><div> Unload Me</div><div></div><div> ActiveCell.Offset(0, 1).Select</div><div></div><div><span class="comment">'ActiveCell.Offset(0, -2) = networkdays(ActiveCell.Offset(0, -3), ActiveCell.Offset(0, -1))</span></div><div><span class="comment">' ActiveCell.Offset(0, -2) = Application.Dia.lab(ActiveCell.Offset(0, -3), ActiveCell.Offset(0, -1))</span></div><div><span class="keyword">End Sub</span></div><hr size="1"><div></div><div><span class="keyword">Private Sub</span> CommandButton3_Click()</div><div></div><div>Unload Me</div><div></div><div><span class="keyword">End Sub</span></div><hr size="1"><div></div><div><span class="keyword">Private Sub</span> SpinButton1_Change()</div><div><span class="keyword">If</span> SpinButton1 >= -1<span class="keyword">And</span> SpinButton1 _</div><div><= 1<span class="keyword">Then</span> dDate = Calendar1</div><div>TextBox1 = SpinButton1</div><div>Calendar1 = DateAdd _</div><div>("m", TextBox1.Value, dDate)</div><div>UpdateCell</div><div><span class="keyword">End Sub</span></div><hr size="1"><div></div><div><span class="keyword">Private Sub</span> SpinButton2_Change()</div><div><span class="keyword">If</span> SpinButton2 >= -1<span class="keyword">And</span> SpinButton2 _</div><div><= 1<span class="keyword">Then</span> dDate = Calendar1</div><div>TextBox2 = SpinButton2</div><div>Calendar1 = DateAdd _</div><div>("ww", TextBox2.Value, dDate)</div><div>UpdateCell</div><div><span class="keyword">End Sub</span></div><hr size="1"><div></div><div><span class="keyword">Private Sub</span> SpinButton3_Change()</div><div><span class="keyword">If</span> SpinButton3 >= -1<span class="keyword">And</span> SpinButton3 _</div><div><= 1<span class="keyword">Then</span> dDate = Calendar1</div><div>TextBox3 = SpinButton3</div><div>Calendar1 = DateAdd _</div><div>("d", TextBox3.Value, dDate)</div><div>UpdateCell</div><div><span class="keyword">End Sub</span></div><hr size="1"><div></div><div><span class="keyword">Private Sub</span> UpdateCell()</div><div>ActiveCell = Calendar1</div><div>ActiveCell.NumberFormat _</div><div>= "dddd, d mmmm yyyy"</div><div><span class="keyword">End Sub</span></div><hr size="1"><div></div><div></div><div><span class="keyword">Private Sub</span> UserForm_Initialize()</div><div>UserForm1.Calendar1.Value = Date</div><div><span class="keyword">End Sub</span></div><div></div><div></div><div></div></nobr></body></html>
Gracias por tu tiempo y paciencia.