Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Not able to copy a VBA array with formulas into an Excel range

Hi,

I am trying to transfer the contents of an array into a range of Excel (red
line in the code below). Though I am able to do that when the array has
values, however, it is giving me an error when the array has formulas.
How can I get this to work?

VBA Code:
...
Dim Vma As Variant
...
TotalRows = .Range("Spread").Count

Vma = Application.Transpose(.Range("Spread"))


For i = TotalRows To 1 Step -1

Vma(i) = "=RC[-2]- RC[-1])"

Next

.Range("Spread") = Application.WorksheetFunction.Transpose(Vma)
...



Thanks,

MG.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200903/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Not able to copy a VBA array with formulas into an Excel range

Your formula isn't valid (the ()'s don't match):

Vma(i) = "=RC[-2]- RC[-1])"
should be:
Vma(i) = "=(RC[-2]- RC[-1]"
or
Vma(i) = "=(RC[-2]- RC[-1])"

I'm not sure if this is a simplified version, but how about:

with worksheets("somesheetnamehere")
.range("Spread").formular1c1 = "=RC[-2]- RC[-1]"
end with

ps. I'd be explicit with the .formular1c1 in your code, too.

"musicgold via OfficeKB.com" wrote:

Hi,

I am trying to transfer the contents of an array into a range of Excel (red
line in the code below). Though I am able to do that when the array has
values, however, it is giving me an error when the array has formulas.
How can I get this to work?

VBA Code:
...
Dim Vma As Variant
...
TotalRows = .Range("Spread").Count

Vma = Application.Transpose(.Range("Spread"))


For i = TotalRows To 1 Step -1

Vma(i) = "=RC[-2]- RC[-1])"

Next

.Range("Spread") = Application.WorksheetFunction.Transpose(Vma)
...

Thanks,

MG.

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200903/1


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Not able to copy a VBA array with formulas into an Excel range

Dave,

Thanks. You are right; the formula was wrong. How silly of me!

MG

Dave Peterson wrote:
Your formula isn't valid (the ()'s don't match):

Vma(i) = "=RC[-2]- RC[-1])"
should be:
Vma(i) = "=(RC[-2]- RC[-1]"
or
Vma(i) = "=(RC[-2]- RC[-1])"

I'm not sure if this is a simplified version, but how about:

with worksheets("somesheetnamehere")
.range("Spread").formular1c1 = "=RC[-2]- RC[-1]"
end with

ps. I'd be explicit with the .formular1c1 in your code, too.

Hi,

[quoted text clipped - 27 lines]
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200903/1



--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200903/1

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 array formulas Scott A[_2_] Excel Discussion (Misc queries) 7 February 1st 09 05:31 PM
Formulas assignment from array to range in VSTO Excel doesn't work vsto excel array to range Excel Worksheet Functions 0 December 11th 07 04:48 PM
Excel automation: Problem with inserting an array of formulas into a range [email protected] Excel Programming 0 September 18th 07 10:43 PM
copy one array formula to an array range guedj54 Excel Programming 2 October 29th 06 07:38 PM
Excel copy formulas using non contiguous range Paul Moles Excel Discussion (Misc queries) 4 March 11th 06 11:07 PM


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