imputbox change decimal value dot to comma

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
36,075
Office Version
365
Platform
Windows
What happens if you put the value straight into the cell
Code:
ValorND = InputBox("Valor da Nota de Débito")
Range("O5").Value = ValorND
 

Some videos you may like

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Blue_Wings

New Member
Joined
Aug 23, 2019
Messages
11
As simple as that!
It Works!

The confusion was because I wanted to use that same variable "ValorND" to do a calculation while inside the VBA with another variable "ValorND / ValorQuota" , and that was causing error Run-time error'13': Type mismatch, so I decided to add an auxiliary variable "ValorNDAux"to deal with that, and now is working.

thanks you.

Code:
    'Imput box para pedir valor de Nota de Débito
    
    Dim ValorND As String
    Dim ValorNDAux As String
    
    Dim ValorQuota As String
    Dim Resultado As String
    
    ValorND = InputBox("Valor da Nota de Débito")
    
    'Valor auxiliar para ser convertido de . para , sem causar erro no "Resultado"
    ValorNDAux = ValorND
    
    'Se for inserido um "ponto" transforma em virgula
    If InStr(1, ValorNDAux, ".") > 0 Then ValorNDAux = Replace(ValorNDAux, ".", ",")
    
  
   
    'Soma a quota com o fundo de reserva para achar o valor total da quota da fração em questão
    
    ValorQuota = WorksheetFunction.Sum(Range("H4:H5"))

    
   
    'Faz o teste para ver se é numero inteiro ou com casas decimais
    
    Resultado = ValorNDAux / ValorQuota
     
    Range("O5").Value = ValorND
 
Last edited:

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
36,075
Office Version
365
Platform
Windows
Glad it's sorted & thanks for the feedback
 

Akuini

Well-known Member
Joined
Feb 1, 2016
Messages
2,563
Office Version
365
Platform
Windows
As simple as that!
It Works!
Hi, Blue_Wings
Just courious, if you enter 5,88 (with comma) then what happen?
My system use comma as decimal separator too, & the result is (using your last code) in cell O5 is string.
Did you try my code in post #10 ?
 
Last edited:

Blue_Wings

New Member
Joined
Aug 23, 2019
Messages
11
Hi, Blue_Wings
Just courious, if you enter 5,88 (with comma) then what happen?
My system use comma as decimal separator too, & the result is (using your last code) in cell O5 is string.
Did you try my code in post #10 ?
I missed your #10 reply and didn´t tried it.

But answering your question, if I entered 5,88 with a comma everything works fine, it was just to avoid error, since most people uses dot from the numeric pad on the keyboard, like this I can use both ways and its always converted to comma so that the system on the spreadsheet can do calculations and doesn´t return any error.
 

Akuini

Well-known Member
Joined
Feb 1, 2016
Messages
2,563
Office Version
365
Platform
Windows
if I entered 5,88 with a comma everything works fine
You mean it inserts number in cell 05? not string?
 

Watch MrExcel Video

Forum statistics

Threads
1,090,363
Messages
5,414,011
Members
403,511
Latest member
Emmanuel John

This Week's Hot Topics

Top