Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Len Len is offline
external usenet poster
 
Posts: 162
Default Copy Array Formula

Hi ,

It seem that the modified VBA code ( ie suggested by OssieMac ) below
can not work when it copies down excel array formula for this
scenario, does it miss out any code ??
Please help, thanks


Sub test()
Dim rng2 As Range
Range("J1").FormulaArray = "=IF(ISERROR(G1-H1),G1,(G1-H1))"
Set rng2 = Range(Cells(1, 2), Cells(Rows.Count, 2).End(xlUp))
Set rng2 = rng2.Offset(0, 8) Cells(1, 10).Copy Destination:=rng2
End Sub


Regards
Len


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Copy Array Formula

LEn,

That formula will error out if you try to copy it to column B, and your
syntax is wrong, anyway.

Try it like this to match column H:

Dim rng2 As Range
Range("J1").FormulaArray = "=IF(ISERROR(G1-H1),G1,(G1-H1))"
Set rng2 = Range("J2", Cells(Rows.Count, 8).End(xlUp).Offset(1, 2))
MsgBox rng2.Address
Range("J1").Copy rng2


HTH,
Bernie
MS Excel MVP


"Len" wrote in message
...
Hi ,

It seem that the modified VBA code ( ie suggested by OssieMac ) below
can not work when it copies down excel array formula for this
scenario, does it miss out any code ??
Please help, thanks


Sub test()
Dim rng2 As Range
Range("J1").FormulaArray = "=IF(ISERROR(G1-H1),G1,(G1-H1))"
Set rng2 = Range(Cells(1, 2), Cells(Rows.Count, 2).End(xlUp))
Set rng2 = rng2.Offset(0, 8) Cells(1, 10).Copy Destination:=rng2
End Sub


Regards
Len



  #3   Report Post  
Posted to microsoft.public.excel.programming
Len Len is offline
external usenet poster
 
Posts: 162
Default Copy Array Formula

On May 15, 10:33*am, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
LEn,

That formula will error out if you try to copy it to column B, and your
syntax is wrong, anyway.

Try it like this to match column H:

Dim rng2 As Range
Range("J1").FormulaArray = "=IF(ISERROR(G1-H1),G1,(G1-H1))"
Set rng2 = Range("J2", Cells(Rows.Count, 8).End(xlUp).Offset(1, 2))
MsgBox rng2.Address
Range("J1").Copy rng2

HTH,
Bernie
MS Excel MVP

"Len" wrote in message

...



Hi ,


It seem that the modified VBA code ( ie suggested by OssieMac ) below
can not work when it copies down excel array formula for this
scenario, does it miss out any code ??
Please help, thanks


Sub test()
Dim rng2 As Range
Range("J1").FormulaArray = "=IF(ISERROR(G1-H1),G1,(G1-H1))"
Set rng2 = Range(Cells(1, 2), Cells(Rows.Count, 2).End(xlUp))
Set rng2 = rng2.Offset(0, 8) Cells(1, 10).Copy Destination:=rng2
End Sub


Regards
Len- Hide quoted text -


- Show quoted text -


Hi Bernie,

Thanks for your code but this VBA code has to copy down the excel
array formula ( ie from J1 ) in column J depending on the last used
cells of column B, then how to rectify the code

Regards
Len

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Copy Array Formula

Len

Dim rng2 As Range
Range("J1").FormulaArray = "=IF(ISERROR(G1-H1),G1,(G1-H1))"
Set rng2 = Range("J2", Cells(Rows.Count, 2).End(xlUp).Offset(1, 8))
MsgBox rng2.Address
Range("J1").Copy rng2

You can take out the Msgbox line...

HTH,
Bernie
MS Excel MVP


Hi Bernie,

Thanks for your code but this VBA code has to copy down the excel
array formula ( ie from J1 ) in column J depending on the last used
cells of column B, then how to rectify the code

Regards
Len

  #5   Report Post  
Posted to microsoft.public.excel.programming
Len Len is offline
external usenet poster
 
Posts: 162
Default Copy Array Formula

On May 15, 7:00*pm, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
Len

Dim rng2 As Range
Range("J1").FormulaArray = "=IF(ISERROR(G1-H1),G1,(G1-H1))"
Set rng2 = Range("J2", Cells(Rows.Count, 2).End(xlUp).Offset(1, 8))
MsgBox rng2.Address
Range("J1").Copy rng2

You can take out the Msgbox line...

HTH,
Bernie
MS Excel MVP

Hi Bernie,

Thanks for your code but this VBA code has to copy down the excel
array formula ( ie from J1 ) in column J depending on the last used
cells of column B, then how to rectify the code

Regards
Len


Hi Bernie,

Sorry, I was away and unable to access pc for almost a week.
Thanks, your codes work

Regards
Len
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
copy one array formula to an array range guedj54 Excel Programming 2 October 29th 06 07:38 PM
How do I copy an array formula? cguen Excel Discussion (Misc queries) 1 August 28th 06 04:42 PM
copy array formula JR573PUTT Excel Worksheet Functions 2 February 16th 06 10:12 PM
copy an array formula JR573PUTT[_3_] Excel Programming 1 February 16th 06 09:11 PM
Copy An Array Formula JR573PUTT Excel Discussion (Misc queries) 2 February 16th 06 08:57 PM


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