PC Review


Reply
Thread Tools Rate Thread

Copy Array Formula

 
 
Len
Guest
Posts: n/a
 
      15th May 2009
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


 
Reply With Quote
 
 
 
 
Bernie Deitrick
Guest
Posts: n/a
 
      15th May 2009
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" <(E-Mail Removed)> wrote in message
news:754413d2-dd12-48c4-9791-(E-Mail Removed)...
> 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
>
>


 
Reply With Quote
 
Len
Guest
Posts: n/a
 
      15th May 2009
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" <ltong2000...@yahoo.co.uk> wrote in message
>
> news:754413d2-dd12-48c4-9791-(E-Mail Removed)...
>
>
>
> > 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

 
Reply With Quote
 
Bernie Deitrick
Guest
Posts: n/a
 
      15th May 2009
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

 
Reply With Quote
 
Len
Guest
Posts: n/a
 
      21st May 2009
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy one array formula to an array range =?Utf-8?B?Z3VlZGo1NA==?= Microsoft Excel Programming 2 29th Oct 2006 07:38 PM
How do I copy an array formula? =?Utf-8?B?Y2d1ZW4=?= Microsoft Excel Misc 1 28th Aug 2006 04:42 PM
copy array formula JR573PUTT Microsoft Excel Worksheet Functions 2 16th Feb 2006 10:12 PM
copy an array formula JR573PUTT Microsoft Excel Programming 1 16th Feb 2006 09:11 PM
Copy An Array Formula JR573PUTT Microsoft Excel Misc 2 16th Feb 2006 08:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:12 AM.