Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 132
Default Display result of operation in macro

Hi All

I have the below subprocedure. I get the numerical right answer when it is
displayed in a selected cell ie Range("A1"), but when I set it to be the
equation of a variable I get "Run Time Error "13" Type Mismatch".

Dim pu As Double
pu = "=COUNTIF(Sheet1!e:e,""*-p*"")"
MsgBox (pu)

Could anyone explain to me why I am getting this error and how can I fix it?

Thanks in advance and Happy Holidays!

Orquidea
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Display result of operation in macro

You're assigning a string to the pu variable. Just because it looks like a
worksheet formula doesn't mean that VBA will evaluate it.

You could try:

dim pu as long 'why use a double?
pu = application.countif(worksheets("sheet1").range("e: e"), "*-p*")
msgbox pu 'no ()'s required here



orquidea wrote:

Hi All

I have the below subprocedure. I get the numerical right answer when it is
displayed in a selected cell ie Range("A1"), but when I set it to be the
equation of a variable I get "Run Time Error "13" Type Mismatch".

Dim pu As Double
pu = "=COUNTIF(Sheet1!e:e,""*-p*"")"
MsgBox (pu)

Could anyone explain to me why I am getting this error and how can I fix it?

Thanks in advance and Happy Holidays!

Orquidea


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 132
Default Display result of operation in macro

Thanks for your help. It worked

"Dave Peterson" wrote:

You're assigning a string to the pu variable. Just because it looks like a
worksheet formula doesn't mean that VBA will evaluate it.

You could try:

dim pu as long 'why use a double?
pu = application.countif(worksheets("sheet1").range("e: e"), "*-p*")
msgbox pu 'no ()'s required here



orquidea wrote:

Hi All

I have the below subprocedure. I get the numerical right answer when it is
displayed in a selected cell ie Range("A1"), but when I set it to be the
equation of a variable I get "Run Time Error "13" Type Mismatch".

Dim pu As Double
pu = "=COUNTIF(Sheet1!e:e,""*-p*"")"
MsgBox (pu)

Could anyone explain to me why I am getting this error and how can I fix it?

Thanks in advance and Happy Holidays!

Orquidea


--

Dave Peterson

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
VBA MACRO 4 ISNUMBER OPERATION FARAZ QURESHI Excel Discussion (Misc queries) 4 July 31st 07 12:14 PM
can excel produce text in a given cell as a result of a boolean operation? Richard Erlacher Excel Discussion (Misc queries) 5 October 26th 06 09:39 PM
Display message during save operation Excelerate-nl Excel Discussion (Misc queries) 4 December 8th 05 07:27 PM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 1 June 11th 05 12:44 AM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 0 June 10th 05 03:38 PM


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

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

About Us

"It's about Microsoft Excel"