Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 139
Default assigning value in macro

Hi
When I want a value for of a formula for my macro I write the formula to go
in a blank cell eg range("a1") ="= countif("b:b",b1)" then use myvalue =
range("a1") how do I assign countif to myvalue without doing this?
Thanks
Tina
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default assigning value in macro


myValue = Application.COUNTIF(Range("B:B"),Range("B1"))

--

HTH

RP
(remove nothere from the email address if mailing direct)


"tina" wrote in message
...
Hi
When I want a value for of a formula for my macro I write the formula to

go
in a blank cell eg range("a1") ="= countif("b:b",b1)" then use myvalue =
range("a1") how do I assign countif to myvalue without doing this?
Thanks
Tina



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default assigning value in macro

Hi Tina !! :)
Try this. It should work.

range("a1") = chr(34) & "=countif(" & chr(34) &"b:b" & chr(34)& ",b1)"&
chr(34)
Could you let me know if it solves your problem ?
My e-mail ID is

"tina" wrote:

Hi
When I want a value for of a formula for my macro I write the formula to go
in a blank cell eg range("a1") ="= countif("b:b",b1)" then use myvalue =
range("a1") how do I assign countif to myvalue without doing this?
Thanks
Tina

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default assigning value in macro

Or:

dim myVal as long
with activesheet
myval = application.countif(.range("b:b"),.range("b1").val ue)
end with
msgbox myval


Vijay Chary wrote:

Hi Tina !! :)
Try this. It should work.

range("a1") = chr(34) & "=countif(" & chr(34) &"b:b" & chr(34)& ",b1)"&
chr(34)
Could you let me know if it solves your problem ?
My e-mail ID is

"tina" wrote:

Hi
When I want a value for of a formula for my macro I write the formula to go
in a blank cell eg range("a1") ="= countif("b:b",b1)" then use myvalue =
range("a1") how do I assign countif to myvalue without doing this?
Thanks
Tina


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
CLR CLR is offline
external usenet poster
 
Posts: 1,998
Default assigning value in macro

Thanks Bob.......

Your suggestion helped me TODAY, 11/29/09!!.......4 1/2 years after you
posted it!

Vaya con Dios,
Chuck, CABGx3





"Bob Phillips" wrote:


myValue = Application.COUNTIF(Range("B:B"),Range("B1"))

--

HTH

RP
(remove nothere from the email address if mailing direct)


"tina" wrote in message
...
Hi
When I want a value for of a formula for my macro I write the formula to

go
in a blank cell eg range("a1") ="= countif("b:b",b1)" then use myvalue =
range("a1") how do I assign countif to myvalue without doing this?
Thanks
Tina




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
assigning macro carrera Excel Discussion (Misc queries) 16 March 21st 08 09:00 PM
assigning a macro to a button Darby Excel Discussion (Misc queries) 2 February 10th 06 05:05 PM
Macro assigning help PLEASE Jim Rech Excel Programming 0 February 10th 04 10:03 PM
Assigning Macro To Shape Tommi[_2_] Excel Programming 2 October 31st 03 10:58 AM
Assigning formula using a macro LSB Excel Programming 1 October 29th 03 01:41 PM


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

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"