Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 116
Default SUmif and declared ranges

I am trying to build a sumif equation to be placed into a cell using vba. I
have declared and set "ColRng " and "RngRef" to ranges. when I try to get
out of this equation I keep getting notified that the comma is causing
problems.

Any insight appreciated

xlApp.Range("j28") = "=sumif(('CPCT DEC'!" & ColRng & ")" &,& 89298,"('CPCT
DEC'!" & RngRef&"))"
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default SUmif and declared ranges

what is the formula you want in the cell after the code runs.

I suspect you want
sSht = "'CPCT DEC'!"
xlApp.Range("J28").Formula = _
"=sumif(" & sSht & colrng.Address & _
",89298," & sSht & RngRef.Address & ")"

so to test out the results using the immediate window with some
representative range assignments:

set colRng = Range("A1:A10")
set RngRef = Range("B1:B10")
? "=sumif(" & sSht & colrng.Address & _
",89298," & sSht & RngRef.Address & ")"

Produces:

=sumif($A$1:$A$10,89298,$B$1:$B$10)

--
Regards,
Tom Ogilvy


"marty" wrote in message
...
I am trying to build a sumif equation to be placed into a cell using vba.

I
have declared and set "ColRng " and "RngRef" to ranges. when I try to get
out of this equation I keep getting notified that the comma is causing
problems.

Any insight appreciated

xlApp.Range("j28") = "=sumif(('CPCT DEC'!" & ColRng & ")" &,&

89298,"('CPCT
DEC'!" & RngRef&"))"



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default SUmif and declared ranges

Left out the top line in the "test"

sSht = "'CPCT DEC'!"
set colRng = Range("A1:A10")
set RngRef = Range("B1:B10")
? "=sumif(" & sSht & colrng.Address & _
",89298," & sSht & RngRef.Address & ")"

Produces:
=sumif('CPCT DEC'!$A$1:$A$10,89298,'CPCT DEC'!$B$1:$B$10)

--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote in message
...
what is the formula you want in the cell after the code runs.

I suspect you want
sSht = "'CPCT DEC'!"
xlApp.Range("J28").Formula = _
"=sumif(" & sSht & colrng.Address & _
",89298," & sSht & RngRef.Address & ")"

so to test out the results using the immediate window with some
representative range assignments:

set colRng = Range("A1:A10")
set RngRef = Range("B1:B10")
? "=sumif(" & sSht & colrng.Address & _
",89298," & sSht & RngRef.Address & ")"

Produces:

=sumif($A$1:$A$10,89298,$B$1:$B$10)

--
Regards,
Tom Ogilvy


"marty" wrote in message
...
I am trying to build a sumif equation to be placed into a cell using

vba.
I
have declared and set "ColRng " and "RngRef" to ranges. when I try to

get
out of this equation I keep getting notified that the comma is causing
problems.

Any insight appreciated

xlApp.Range("j28") = "=sumif(('CPCT DEC'!" & ColRng & ")" &,&

89298,"('CPCT
DEC'!" & RngRef&"))"





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default SUmif and declared ranges

xlApp.Range("j28") = "=sumif('CPCT DEC'!" & ColRng & ","" 89298"",'CPCT
DEC'!" & RngRef & ")"

--

HTH

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


"marty" wrote in message
...
I am trying to build a sumif equation to be placed into a cell using vba.

I
have declared and set "ColRng " and "RngRef" to ranges. when I try to get
out of this equation I keep getting notified that the comma is causing
problems.

Any insight appreciated

xlApp.Range("j28") = "=sumif(('CPCT DEC'!" & ColRng & ")" &,&

89298,"('CPCT
DEC'!" & RngRef&"))"



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
Sumif and Specified Ranges MstgSally Excel Worksheet Functions 2 January 12th 10 10:20 PM
Reference a variable declared in VBA James Excel Worksheet Functions 3 September 12th 08 10:31 PM
Macro for autofilter using variables declared in worksheet Jeff Excel Worksheet Functions 2 June 14th 05 03:38 AM
Transfering Declared value through procedures FISH Excel Programming 2 December 15th 04 04:25 PM
Can Not Find declared dll Ian Parker[_2_] Excel Programming 0 February 5th 04 10:50 PM


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