Textbox

aaguioli

Board Regular
Joined
Mar 19, 2003
Messages
61
Hola ¡¡¡

Estoy asignando un textbox a una celda, pero no se como agregar las propiedades para que ese valor lo considere un numero, fecha, etc, ya que todos los valores me los devuelve a la celda como texto.

El código que estoy poniendo es el siguiente:

Private Sub TextBox1_Change()
Range("B2").Select
ActiveCell.FormulaR1C1 = TextBox1

End Sub

De antemano gracias por la respuesta.

Saludos Cordiales,
Alberto.
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Por un buen rato me tuvo perplejo porque creí que usted estaba hablando de un TextBox de tipo Shape. Por fin me di cuenta que estaba hablando de un TextBox en un UserForm...

Creo que algo como el siguiente le serviría:

<font face=Courier New>

<SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> TextBox1_Exit(<SPAN style="color:#00007F">ByVal</SPAN> Cancel <SPAN style="color:#00007F">As</SPAN> MSForms.ReturnBoolean)
    <SPAN style="color:#00007F">Dim</SPAN> varX <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Variant</SPAN>
    varX = TextBox1.Value
    <SPAN style="color:#00007F">If</SPAN> IsDate(varX) <SPAN style="color:#00007F">Then</SPAN>
        [B2] = <SPAN style="color:#00007F">CDate</SPAN>(varX)
    <SPAN style="color:#00007F">ElseIf</SPAN> IsNumeric(varX) <SPAN style="color:#00007F">Then</SPAN>
        [B2] = <SPAN style="color:#00007F">CDbl</SPAN>(varX)
    <SPAN style="color:#00007F">Else</SPAN>
        [B2] = varX
    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>

Saludos
 
Upvote 0

Forum statistics

Threads
1,223,938
Messages
6,175,526
Members
452,651
Latest member
wordsearch

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