Mateus 0 Posted January 31, 2019 Report Share Posted January 31, 2019 Tenho um VBA no Excel, entretanto o comando salva os lançamentos como texto, então não é possível aplicar qualquer fórmula. Já fiz algumas tentativas e pesquisa mas todas foram fracassadas, segue os códigos: Private Sub CommandButton_gravar_Click() Dim valor As Currency Dim data As Date valor = TextBox_valor data = TextBox_data Range("b11").Select If Range("b12").Value <> "" Then Selection.End(xlDown).Select End If ActiveCell.Offset(1, 0).Select Selection.Value = TextBox_data ActiveCell.Offset(0, 1).Select Selection.Value = ComboBox_categoria ActiveCell.Offset(0, 1).Select Selection.Value = TextBox_historico ActiveCell.Offset(0, 1).Select Selection.Value = ComboBox_movimento ActiveCell.Offset(0, 1).Select Selection.Value = TextBox_valor Unload UserForm_lançamento Também tentei fazer um teste após o lançamento para converter em numero mas não funcionou For Each cell In [f1:f50000] If cell > "" Then numero = (cell.Value) cell.Activate ActiveCell.FormulaR1C1 = numero Else End If Next Minha última tentativa em converter o texto foi adicionar a seguinte linha de código Selection.Value = TextBox_valor Selection.NumberFormat = "$#,##0.00" Link to post Share on other sites
Gnrtuga 21 Posted January 31, 2019 Report Share Posted January 31, 2019 Boas aparentemente o teu problema é que estás a receber o valor que vem da textbox, que é uma string e estás a atribuir a uma variável, onde supostamente queres receber um número. valor = TextBox_valor , mas para isso tens que o converter primeiro, o que será qualquer coisa como valor = Cint(TextBox_valor). Não tenho a certeza de que a conversão seja assim, mas experimenta. Podes ver mais sobre conversões aqui: https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/functions/type-conversion-functions Boa sorte Férias! Estou por aqui: http://maps.google.p...001549&t=h&z=20 (a bulir claro está!) Nunca mais é verão outra vez.. Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now