|
-
Sep 6th, 2005, 02:31 AM
#1
Thread Starter
Lively Member
Excel and VBA
Hi all.
I have a question here regarding MS Excel.
I have a data (see VSM1.jpg) that I loaded from MS Access to MS Excel.
Can VBA change the layout of the data in VSM1.jpg into VSM2.jpg?
Thanks in advance.
-
Sep 6th, 2005, 05:18 AM
#2
New Member
-
Sep 6th, 2005, 05:52 AM
#3
Re: Excel and VBA
You could.
You might want to read up on pivot table first though...
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Sep 6th, 2005, 08:18 AM
#4
Thread Starter
Lively Member
Re: Excel and VBA
How? Can u show me some example?
-
Sep 6th, 2005, 08:25 AM
#5
Hyperactive Member
Re: Excel and VBA
Hi..
If i understand correctly...this is what the code that helps u...
Just select the cells that u want ...and say "Copy"..
ofter run the fallowing code..
VB Code:
Range("a1").PasteSpecial xlPasteAll, xlPasteSpecialOperationNone, , True
thanx & regards
Anu.
The Difference between a Successful person and others is not a Lack of Knowledge,
But rather a Lack of WILL 
-
Sep 6th, 2005, 02:13 PM
#6
Re: Excel and VBA
Hi,
What nagasrikanth is actually saying there is to use the Transpose method - that is the purpose of the "True" in the pastespecial parameters. Transpose swaps rows and columns, but only when pasting. So, you'd need to copy the cells and paste using this.
The alternative, if it was all to be done in a single workbook and you didn't want to get involved with cutting and pasting would be to stick it all in an array and then write it back out again. Slower for large grids, but pretty easy.
VB Code:
Dim myarray(3,3) as variant
for i = 1 to 3
for j = 1 to 3
myarray(i,j) = cells(i,j)
next j
next i
for i = 1 to 3
for j = 1 to 3
cells(j,i) = myarray(i,j)
next j
next i
You can make myarray as big as you like in rows and columns. You can't combine the loops because you're overwriting the same cells.
HTH
zaza
-
Sep 6th, 2005, 10:46 PM
#7
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|