Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Error in entering a formula

Hi,

I am trying to create an array formula through VBA code. I want the formula(
for a particular parameter) to appear like this in Excel
{=SUM(IF(Q9:Q11<"Rejected",I9:I11,0))}

The code is this
Fml = "=SUM(IF(Q9:Q" & (RowIndex - 1) & "<" & "Rejected" & ",I9:I" &
(RowIndex - 1) & ",0))"
Dsheet.Range(tmp).FormulaArray = Fml

This code makes it look like =SUM(IF(Q9:Q11<Rejected,I9:I11,0)) [ Rejected
without quotes and hence gives error #NAME?

If I change the VBA code to

Fml = "=SUM(IF(Q9:Q" & (RowIndex - 1) & "<" & ' "Rejected" ' & ",I9:I" &
(RowIndex - 1) & ",0))"

OR

Fml = "=SUM(IF(Q9:Q" & (RowIndex - 1) & "<" & " 'Rejected' " & ",I9:I" &
(RowIndex - 1) & ",0))"

it gives error.

I dnt understand what is the problem with quotes!

TIA
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Error in entering a formula

Hi Ships,

See Bob Phillips response in your earlier thread.

Bob has shown you hoe to enter an array formula.


---
Regards,
Norman


"Shilps" wrote in message
...
Hi,

I am trying to create an array formula through VBA code. I want the
formula(
for a particular parameter) to appear like this in Excel
{=SUM(IF(Q9:Q11<"Rejected",I9:I11,0))}

The code is this
Fml = "=SUM(IF(Q9:Q" & (RowIndex - 1) & "<" & "Rejected" & ",I9:I" &
(RowIndex - 1) & ",0))"
Dsheet.Range(tmp).FormulaArray = Fml

This code makes it look like =SUM(IF(Q9:Q11<Rejected,I9:I11,0)) [
Rejected
without quotes and hence gives error #NAME?

If I change the VBA code to

Fml = "=SUM(IF(Q9:Q" & (RowIndex - 1) & "<" & ' "Rejected" ' & ",I9:I" &
(RowIndex - 1) & ",0))"

OR

Fml = "=SUM(IF(Q9:Q" & (RowIndex - 1) & "<" & " 'Rejected' " & ",I9:I" &
(RowIndex - 1) & ",0))"

it gives error.

I dnt understand what is the problem with quotes!

TIA



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Error in entering a formula

Didn't help :(

"Norman Jones" wrote:

Hi Ships,

See Bob Phillips response in your earlier thread.

Bob has shown you hoe to enter an array formula.


---
Regards,
Norman


"Shilps" wrote in message
...
Hi,

I am trying to create an array formula through VBA code. I want the
formula(
for a particular parameter) to appear like this in Excel
{=SUM(IF(Q9:Q11<"Rejected",I9:I11,0))}

The code is this
Fml = "=SUM(IF(Q9:Q" & (RowIndex - 1) & "<" & "Rejected" & ",I9:I" &
(RowIndex - 1) & ",0))"
Dsheet.Range(tmp).FormulaArray = Fml

This code makes it look like =SUM(IF(Q9:Q11<Rejected,I9:I11,0)) [
Rejected
without quotes and hence gives error #NAME?

If I change the VBA code to

Fml = "=SUM(IF(Q9:Q" & (RowIndex - 1) & "<" & ' "Rejected" ' & ",I9:I" &
(RowIndex - 1) & ",0))"

OR

Fml = "=SUM(IF(Q9:Q" & (RowIndex - 1) & "<" & " 'Rejected' " & ",I9:I" &
(RowIndex - 1) & ",0))"

it gives error.

I dnt understand what is the problem with quotes!

TIA




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Error in entering a formula

Hi Ships,

'-----------------
See Bob Phillips response in your earlier thread.


Bob has shown you hoe to enter an array formula.


Didn't help :(

'-----------------

Then the polite (and most efficient) course of action
would be to post an explantory response in that thread.

Personally, I find that Bob's reponses are invariably
extremely useful


---
Regards,
Norman


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Error in entering a formula

Works for me.
Maybe a bit more explanation on your part would help you to a solution.

NickHK

"Shilps" wrote in message
...
Didn't help :(

"Norman Jones" wrote:

Hi Ships,

See Bob Phillips response in your earlier thread.

Bob has shown you hoe to enter an array formula.


---
Regards,
Norman


"Shilps" wrote in message
...
Hi,

I am trying to create an array formula through VBA code. I want the
formula(
for a particular parameter) to appear like this in Excel
{=SUM(IF(Q9:Q11<"Rejected",I9:I11,0))}

The code is this
Fml = "=SUM(IF(Q9:Q" & (RowIndex - 1) & "<" & "Rejected" & ",I9:I" &
(RowIndex - 1) & ",0))"
Dsheet.Range(tmp).FormulaArray = Fml

This code makes it look like =SUM(IF(Q9:Q11<Rejected,I9:I11,0)) [
Rejected
without quotes and hence gives error #NAME?

If I change the VBA code to

Fml = "=SUM(IF(Q9:Q" & (RowIndex - 1) & "<" & ' "Rejected" ' &

",I9:I" &
(RowIndex - 1) & ",0))"

OR

Fml = "=SUM(IF(Q9:Q" & (RowIndex - 1) & "<" & " 'Rejected' " &

",I9:I" &
(RowIndex - 1) & ",0))"

it gives error.

I dnt understand what is the problem with quotes!

TIA








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Error in entering a formula

You could use =sumif():

Option Explicit
Sub testme()
Dim RowIndex As Long
Dim myCell As Range

With ActiveSheet
Set myCell = .Range("a1") 'something
RowIndex = 32 'something
myCell.Formula _
= "=sumif(q9:q1" & RowIndex - 1 _
& ",""<""&""Rejected"",i9:i" & RowIndex - 1 & ")"
End With
End Sub

Shilps wrote:

Hi,

I am trying to create an array formula through VBA code. I want the formula(
for a particular parameter) to appear like this in Excel
{=SUM(IF(Q9:Q11<"Rejected",I9:I11,0))}

The code is this
Fml = "=SUM(IF(Q9:Q" & (RowIndex - 1) & "<" & "Rejected" & ",I9:I" &
(RowIndex - 1) & ",0))"
Dsheet.Range(tmp).FormulaArray = Fml

This code makes it look like =SUM(IF(Q9:Q11<Rejected,I9:I11,0)) [ Rejected
without quotes and hence gives error #NAME?

If I change the VBA code to

Fml = "=SUM(IF(Q9:Q" & (RowIndex - 1) & "<" & ' "Rejected" ' & ",I9:I" &
(RowIndex - 1) & ",0))"

OR

Fml = "=SUM(IF(Q9:Q" & (RowIndex - 1) & "<" & " 'Rejected' " & ",I9:I" &
(RowIndex - 1) & ",0))"

it gives error.

I dnt understand what is the problem with quotes!

TIA


--

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
Entering Formula - Cannot select cell as it is hidden by formula Jim Excel Worksheet Functions 0 March 25th 10 07:22 AM
Help - error entering data into cell NEHicks Excel Worksheet Functions 0 October 2nd 09 04:59 PM
error message 91 when entering wrong data eyesonly1965[_15_] Excel Programming 2 May 13th 06 04:22 PM
Error when entering a formula ken4capitola Excel Programming 6 November 23rd 05 08:21 AM
Error when entering and exiting excel Randy Excel Discussion (Misc queries) 1 January 11th 05 03:17 PM


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