By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,384 Members | 671 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,384 IT Pros & Developers. It's quick & easy.

grouping columns in Excel by VBA

P: 3
Hi all!
I need help with Visual Basic Application 6.0 and Excel.
Problem is that I need group some columns in Excel by Macro in VBA.
Columns are not fixed which mean that every time when a program starts columns
get changed. So that columns I calculate and put them in string.
How can I group those columns in Excel document? I was trying something like
Range (String).group but that doesn't work.
Sep 21 '07 #1
Share this Question
Share on Google+
3 Replies


kadghar
Expert 100+
P: 1,295
Hi all!
I need help with Visual Basic Application 6.0 and Excel.
Problem is that I need group some columns in Excel by Macro in VBA.
Columns are not fixed which mean that every time when a program starts columns
get changed. So that columns I calculate and put them in string.
How can I group those columns in Excel document? I was trying something like
Range (String).group but that doesn't work.
I didnt undersand exactly what you need, but his tips might be of help:

range(cells(1,1), cells(5,3)).select

will select the range A1:C5
if you want to have an excel range into an array, the easiest way is to import it into an array of variants

Dim a
a= range(cells(1,1), cells(1,1).end(-4121).end(-4161))

using END will have the same efect as (Ctr + arrow) , you can use excel constants instead of that numbers, but they wont work if you are not using VBA in excel.

HTH
Sep 21 '07 #2

P: 3
First thank you for your time and answer!
I try what you say but maybe I didn't explain my problem correctly.
I want to make same macro who will group my items in pivot table. Every time when macro is starting he chooses new Pivot Items and then he have to group them. I calculated in what field I have to start and end group but I have filing that grouping is connect only with pivot items not with cells of excel. So obviously I had wrong idea.
Could you help me?
Thank you!
Sep 24 '07 #3

P: 3
I did it!!
But now I have another problem and he is how to change name of pivot items in column which is grouped.
I tried with
pivotTables().pivotFields().pivotItem.Name=
or pivotItem.Caption= ,
if we resume that there is only one pivot item in field.
Thanks
Sep 24 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.