Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ray Ray is offline
external usenet poster
 
Posts: 267
Default Translate to code

Hi -

I'd like to translate the following formula (which works in Excel) to
work in VBA code:
=SUMPRODUCT((LEFT($C$3:$C$100,6)="UNICEF")*($G$3:$ G$100))
(Note: entered as an ARRAY formula)

Thanks, Ray
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Translate to code

Ray,

Try this, assuming you want the formula entered in A3:

Range("A3").Formula = "=SUMPRODUCT((LEFT(C3:C100,6)=""UNICEF"")*(G3:G100 ))"

By the way, you don't have to enter that formula as an array formula.

hth,

Doug

"Ray" wrote in message
...
Hi -

I'd like to translate the following formula (which works in Excel) to
work in VBA code:
=SUMPRODUCT((LEFT($C$3:$C$100,6)="UNICEF")*($G$3:$ G$100))
(Note: entered as an ARRAY formula)

Thanks, Ray



  #3   Report Post  
Posted to microsoft.public.excel.programming
Ray Ray is offline
external usenet poster
 
Posts: 267
Default Translate to code

Hi Doug -

I didn't clearly communicate what I actually needed to do ... sorry
for confusion. The requested formula will be part of a much larger
macro that is essentially transferring data from a daily 'dummy' file
to a standardized template. Most of the data being transferred is on
a one-to-one basis, so a simple application.vlookup works quite
nicely ... BUT several items starting with the word "UNICEF" will
exist in the base file, so there's a many-to-one relationship.

I was hoping to use application.sumif or application.sumproduct but
apparently these don't exist in VBA ... any ideas?

thanks for your time!

regards ,ray

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Translate to code

Ray,

Most VBA- accessible Excel functions are accessed like:

Application.WorksheetFunction.SumIf or
Application.WorksheetFunction.SumProduct

hth,

Doug

"Ray" wrote in message
...
Hi Doug -

I didn't clearly communicate what I actually needed to do ... sorry
for confusion. The requested formula will be part of a much larger
macro that is essentially transferring data from a daily 'dummy' file
to a standardized template. Most of the data being transferred is on
a one-to-one basis, so a simple application.vlookup works quite
nicely ... BUT several items starting with the word "UNICEF" will
exist in the base file, so there's a many-to-one relationship.

I was hoping to use application.sumif or application.sumproduct but
apparently these don't exist in VBA ... any ideas?

thanks for your time!

regards ,ray



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Translate to code

Sub ray()
zum = 0
For i = 3 To 100
If Left(Cells(i, "C").Value, 6) = "UNICEF" Then
zum = zum + Cells(i, "G").Value
End If
Next
MsgBox (zum)
End Sub

--
Gary''s Student - gsnu2007k


  #6   Report Post  
Posted to microsoft.public.excel.programming
Ray Ray is offline
external usenet poster
 
Posts: 267
Default Translate to code

GS -

A few more lines of code, but a little smoother I think ... plus, a
good solution applicable to many other situations I've seen!

Thanks to both of you for your time!

br/ray
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
Some Help Please to Translate an Excel Macro into VB.Net Code eBob.com[_3_] Excel Programming 3 August 26th 07 07:12 PM
Could someone HELP TRANSLATE this simple psuedo code into MACRO pl bxc2739[_3_] Excel Programming 1 April 27th 06 07:46 PM
Could someone HELP TRANSLATE this simple psuedo code into MACRO please?! bxc2739 Excel Discussion (Misc queries) 3 April 27th 06 06:53 PM
translate ws formula to vba code L Scholes Excel Programming 2 April 17th 06 03:34 AM
Anybody translate VB for PC to VB for Mac? This Guy Excel Programming 2 November 2nd 03 04:33 PM


All times are GMT +1. The time now is 11:17 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"