Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default Type Mismatch

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Type Mismatch

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 225
Default Type Mismatch

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 253
Default Type Mismatch

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 333
Default Type Mismatch

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Type Mismatch: array or user defined type expected ExcelMonkey Excel Programming 4 July 6th 06 03:40 PM
Type mismatch using rnge as Range with Type 8 Input Box STEVE BELL Excel Programming 11 December 3rd 05 05:02 AM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM
Type Mismatch on some PCs Delboy Excel Programming 8 January 17th 05 11:37 AM
Type mismatch teresa Excel Programming 1 December 14th 04 11:19 PM


All times are GMT +1. The time now is 10:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"