Enkelt problem med att returnera ett värde istället för text

Loranga

New Member
Joined
Jan 30, 2007
Messages
36
Aloha (Fairwinds...;) )


Jag har ett enkelt problem, nämligen när jag tar ett värde från en textbox i ett userform och sedan skickar det värdet till en cell så blir talet sparat som text.

Det ställer till problem eftersom jag då exempelvis måste skriva 5.5 istället för 5,5 i textboxen för att det ska fungera.

Här är en litet utklipp av min kod

Code:
txtTimmar.Value = ""
Code:
ActiveCell.Offset(0, 7) = txtTimmar.Value
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Hej!

VBA har inga nationella inställningar.
D.v.s för att känna igen ett tal som är inskrivet som text måste det ha punkt som separator.

Testa att göra något i denna stilen:

Code:
Sub xxx()
x = InputBox("Skriv in ditt tal!")
x = Val(WorksheetFunction.Substitute(x, ",", "."))
Range("A1") = x
End Sub

Oavsett om du skriver in punkt eller komma så kommer nu variabeln att innehålla ett tal. Som sedan visas som du vill beroende på dina nationella inställningar i Excel
 
Upvote 0

Forum statistics

Threads
1,216,084
Messages
6,128,721
Members
449,465
Latest member
TAKLAM

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