Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 22nd, 2006, 02:43 PM
Registered User
 
Join Date: Sep 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Vba Consolidate Syntax

Can someone please tell me what is wrong with this syntax? I recorded the macro, then tried to build it in a vba script so I could use variables and arrays, etc to go thru lots of workbooks.

This is to put quotes around the worsheet name...
RollUpToWs = DoubleQuote & RollUpToWs & DoubleQuote

Worksheets(RollUpToWs).Range("TargetImpact").Conso lidate Sources:=MyArrayString

Here is MyArrayString:
Array('C:\Documents and Settings\Administrator\My Documents\Cost Tracking\Rollups\[TestWB.xls]Sheet1'!R21C8:R24C10,'C:\Documents and Settings\Administrator\My Documents\Cost Tracking\Rollups\[TestWB.xls]Sheet2'!R21C8:R24C10),Function:=xlSum TopRow:=False, LeftColumn:=False, CreateLinks:=False

Any help is greatly appreciated!
Regards,
glr
 
Old September 24th, 2006, 09:10 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi Grouth

The problem might be in the array string

Change the string to

MyArrayString =
Array('C:\Documents and Settings\Administrator\My Documents\Cost Tracking\Rollups\[TestWB.xls]Sheet1'!R21C8:R24C10,'C:\Documents and Settings\Administrator\My Documents\Cost Tracking\Rollups\[TestWB.xls]Sheet2'!R21C8:R24C10) and [b]assign it to source[/b[

and separate the rest to another string

Function:=xlSum TopRow:=False, LeftColumn:=False, CreateLinks:=False


http://www.vbadud.blogspot.com
 
Old September 27th, 2006, 01:40 PM
Registered User
 
Join Date: Sep 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It still encounters the '1004' error at this line:
Selection.Consolidate Sources:=Source & ",Function:=xlSum TopRow:=False, LeftColumn:=False, CreateLinks:=False"

The value of Source (from the immediate window) is:
Array('C:\Documents and Settings\grouth\My Documents\Cost Tracking DEV\Rollups\[TestWB.xls]Sheet1'!R21C8:R24C10,'C:\Documents and Settings\grouth\My Documents\Cost Tracking DEV\Rollups\[TestWB.xls]Sheet2'!R21C8:R24C10)

Any other suggestions are most appreciated.
Gary
 
Old September 29th, 2006, 07:37 PM
Registered User
 
Join Date: Sep 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the help. As it turns out, I was trying to write the contents of the string that goes between the parenthesis, e.g. Array(). I was trying to put in the quotes, commas, etc. All I really needed to do was to loop through the array, putting the path and range, and let VBA put the punctuation in for me.

Shasur, thanks again for your assistance!

Regards,

Gary






Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Syntax in VBA? Bill_L Excel VBA 0 September 11th, 2008 08:47 AM
Fields object syntax in VBA query stepdev Access VBA 11 March 3rd, 2006 04:53 PM
How can use sql syntax in excel vba Biggladius Excel VBA 4 October 6th, 2004 04:15 AM
help with VBA syntax jacqui Excel VBA 0 January 12th, 2004 02:08 PM
Word VBA Syntax Needed SerranoG VB How-To 4 October 28th, 2003 02:16 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.