Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I am getting an error 13: Type Mismatch and don't understand why. Would someone clarify this for me? Sub SaveItems(AmountCol, Choice, ItemAmount) Dim ws As Worksheet Set ws = Tablespg With ws With .Range(AmountCol & Choice) .Value = Val(ItemAmount) .NumberFormat = "_(* #,##0.00_);_(* (#,##0.00);_(* " - "??_);_(@_)" End With End With End Sub The error occurs at the .NumberFormat statement. ItemAmount is a value obtained from a textbox then converted to a number in the .Value statement. -- Thanks for your help. Karen53 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What is in AmountCol, Choice and ItemAmount. My guess is that one of those
is invalid -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Karen53" wrote in message ... Hi, I am getting an error 13: Type Mismatch and don't understand why. Would someone clarify this for me? Sub SaveItems(AmountCol, Choice, ItemAmount) Dim ws As Worksheet Set ws = Tablespg With ws With .Range(AmountCol & Choice) .Value = Val(ItemAmount) .NumberFormat = "_(* #,##0.00_);_(* (#,##0.00);_(* " - "??_);_(@_)" End With End With End Sub The error occurs at the .NumberFormat statement. ItemAmount is a value obtained from a textbox then converted to a number in the .Value statement. -- Thanks for your help. Karen53 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The minus sign in the .NumberFormat line makes
no sense - the type mismatch is complaining about that, because you're trying to subtract one string from another. You just need something like: ..NumberFormat = "_(* #,##0.00_);_(* (#,##0.00);_(*??_);_(@_)" On 18 Dec, 15:45, Karen53 wrote: Hi, I am getting an error 13: Type Mismatch and don't understand why. Would someone clarify this for me? Sub SaveItems(AmountCol, Choice, ItemAmount) Dim ws As Worksheet Set ws = Tablespg With ws With .Range(AmountCol & Choice) .Value = Val(ItemAmount) .NumberFormat = "_(* #,##0.00_);_(* (#,##0.00);_(* " - "??_);_(@_)" End With End With End Sub The error occurs at the .NumberFormat statement. ItemAmount is a value obtained from a textbox then converted to a number in the .Value statement. -- Thanks for your help. Karen53 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Karen,
After test, it comes from the string format argument itself. OK "_(* #,##0.00_);_(* (#,##0.00))" Not OK "_(* #,##0.00_);_(* (#,##0.00);_(* " - "??_);_(@_)" Try recording a macro to get the format argument correctly set. Regards JY "Karen53" wrote in message ... Hi, I am getting an error 13: Type Mismatch and don't understand why. Would someone clarify this for me? Sub SaveItems(AmountCol, Choice, ItemAmount) Dim ws As Worksheet Set ws = Tablespg With ws With .Range(AmountCol & Choice) .Value = Val(ItemAmount) .NumberFormat = "_(* #,##0.00_);_(* (#,##0.00);_(* " - "??_);_(@_)" End With End With End Sub The error occurs at the .NumberFormat statement. ItemAmount is a value obtained from a textbox then converted to a number in the .Value statement. -- Thanks for your help. Karen53 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks to all. I got it working.
-- Thanks for your help. Karen53 "Karen53" wrote: Hi, I am getting an error 13: Type Mismatch and don't understand why. Would someone clarify this for me? Sub SaveItems(AmountCol, Choice, ItemAmount) Dim ws As Worksheet Set ws = Tablespg With ws With .Range(AmountCol & Choice) .Value = Val(ItemAmount) .NumberFormat = "_(* #,##0.00_);_(* (#,##0.00);_(* " - "??_);_(@_)" End With End With End Sub The error occurs at the .NumberFormat statement. ItemAmount is a value obtained from a textbox then converted to a number in the .Value statement. -- Thanks for your help. Karen53 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Type Mismatch: array or user defined type expected | Excel Programming | |||
Type mismatch using rnge as Range with Type 8 Input Box | Excel Programming | |||
Help: Compile error: type mismatch: array or user defined type expected | Excel Programming | |||
Type Mismatch on some PCs | Excel Programming | |||
Type mismatch | Excel Programming |