Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Excel Copy/Transpose

Posted on 2013-01-14
10
Medium Priority
?
297 Views
Last Modified: 2013-01-16
Hello,
can you please help with a VB Code.

I tried to put it in color to explain the copy and paste.

The paste starts at A170.

Any help is appreciated.
Sample.xlsx
0
Comment
Question by:W.E.B
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 26

Expert Comment

by:redmondb
ID: 38776208
Hi, Wass_QA.

Edit: Corrected.

Please see attached. The code is...
Option Explicit

Sub Copy_Two_Columns()
ThisWorkbook.Sheets("Sheet1").Activate

Range("A7:D138").Copy Destination:=Range("D170")
Range("A7:C138").Copy Destination:=Range("D302")
Range("E7:E138").Copy Destination:=Range("G302")
Range("D4:D6").Copy
Range("A170:C301").PasteSpecial Paste:=xlPasteAll, Transpose:=True
Range("E4:E6").Copy
Range("A302:C433").PasteSpecial Paste:=xlPasteAll, Transpose:=True

Range("C170:C433").Font.Bold = False

Application.CutCopyMode = False

Application.Goto Reference:="R1C1"

End Sub

Open in new window

Regards,
Brian. Sample-V3.xlsm
0
 

Author Comment

by:W.E.B
ID: 38776290
Hello redmondb,
Thanks for your help,

I didn't mean only 2 columns, (this was only an example)
the code should be for the rest of the sheet as well.

Thanks,
0
 
LVL 26

Expert Comment

by:redmondb
ID: 38776338
Wass_QA,

OK, I think I see what you mean now.

Couple of questions, please...
(1) Will EE always be the last column?
(2) Will row 138 always be the last row?

Thanks,
Brian.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:W.E.B
ID: 38776352
Hello,
no, they differ depends on the client.

thanks again.
0
 
LVL 26

Expert Comment

by:redmondb
ID: 38776410
Wass_QA,

I had the attached done before I saw your post. Please check that the principle is correct while I meake the size generic.

A couple of follow ons, please...
(3) If the no, of rows is variable, what about the first destination row? Is that always 170 or is it a set number of rows below the main data?
(4) May I assume that A4:C6 are the only embedded blanks?

Thanks,
Brian.
(5)
Sample-V4.xlsm
0
 

Author Comment

by:W.E.B
ID: 38776454
Hello,
I tried the code, it works on the sample File.
but, If I remove some Columns or Rows, It still copies more columns.

(3)Is that always 170 or is it a set number of rows below the main data? Correct

(4) May I assume that A4:C6 are the only embedded blanks? Correct

Thanks,
0
 
LVL 26

Expert Comment

by:redmondb
ID: 38776525
Thanks, Wass_QA.

If I remove some Columns or Rows, It still copies more columns.
That's what I expected - that version was done before I saw your post about variable columns/rows.

(3)Is that always 170 or is it a set number of rows below the main data? Correct
Which - is it always 170?

Thanks,
Brian.
0
 
LVL 26

Accepted Solution

by:
redmondb earned 1600 total points
ID: 38776535
Wass_QA,

Please see my previous post - the attached assumes that row 170 is constant.

Regards,
Brian.
Sample-V5.xlsm
0
 

Author Closing Comment

by:W.E.B
ID: 38776544
Excellent help.
Thank you very much.
0
 
LVL 26

Expert Comment

by:redmondb
ID: 38785164
Glad to help, Wass_QA!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question