ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Transpose to Non-adjacent Cells (https://www.excelbanter.com/excel-programming/380272-transpose-non-adjacent-cells.html)

DennisW

Transpose to Non-adjacent Cells
 
I'm trying to transpose selected rows of data from a worksheet to columns on
multiple worksheets, however the transposed columnar data will be on
non-adjacent rows. I loop through the rows, columns, and worksheets. Part
of the code within the loops is:

Sheets("Equip").Activate
Range(Cells(m, 2), Cells(m, 5)).Copy
Sheets(s).Cells(7, c).PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True

Sheets("Equip").Range(Cells(m, 7)).Copy
Destination:=Sheets(s).Range(Cells(12, c))

The transpose part of the code works, but I don't know why the second part
fails where I'm just trying to copy a single cell.

Any help?




Chip Pearson

Transpose to Non-adjacent Cells
 
I think the problem lies with the line

Sheets("Equip").Range(Cells(m, 7)).Copy _
Destination:=Sheets(s).Range(Cells(12, c))

Your Cells properties are not qualified to point to the proper worksheet.
Without qualification, they point to the ActiveSheet, which may not be
"Equip" or the sheet named by the variable 's'.

Also, your use of Range with Cells is unnecessary. Try the following:

Sheets("Equip").Cells(M, 7).Copy _
Destination:=Sheets(S).Cells(12, C)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)




"DennisW" wrote in message
...
I'm trying to transpose selected rows of data from a worksheet to columns
on
multiple worksheets, however the transposed columnar data will be on
non-adjacent rows. I loop through the rows, columns, and worksheets.
Part
of the code within the loops is:

Sheets("Equip").Activate
Range(Cells(m, 2), Cells(m, 5)).Copy
Sheets(s).Cells(7, c).PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True

Sheets("Equip").Range(Cells(m, 7)).Copy
Destination:=Sheets(s).Range(Cells(12, c))

The transpose part of the code works, but I don't know why the second part
fails where I'm just trying to copy a single cell.

Any help?






DennisW

Transpose to Non-adjacent Cells
 
Thanks for your help. I actually found a solution:

Sheets("Equip").Cells(m, 7).Copy
Sheets(s).Cells(12, c).PasteSpecial Paste:=xlPasteValues

Sorry for the inconvenience, I just started trying to learn VBA.

"Chip Pearson" wrote:

I think the problem lies with the line

Sheets("Equip").Range(Cells(m, 7)).Copy _
Destination:=Sheets(s).Range(Cells(12, c))

Your Cells properties are not qualified to point to the proper worksheet.
Without qualification, they point to the ActiveSheet, which may not be
"Equip" or the sheet named by the variable 's'.

Also, your use of Range with Cells is unnecessary. Try the following:

Sheets("Equip").Cells(M, 7).Copy _
Destination:=Sheets(S).Cells(12, C)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)




"DennisW" wrote in message
...
I'm trying to transpose selected rows of data from a worksheet to columns
on
multiple worksheets, however the transposed columnar data will be on
non-adjacent rows. I loop through the rows, columns, and worksheets.
Part
of the code within the loops is:

Sheets("Equip").Activate
Range(Cells(m, 2), Cells(m, 5)).Copy
Sheets(s).Cells(7, c).PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True

Sheets("Equip").Range(Cells(m, 7)).Copy
Destination:=Sheets(s).Range(Cells(12, c))

The transpose part of the code works, but I don't know why the second part
fails where I'm just trying to copy a single cell.

Any help?








All times are GMT +1. The time now is 02:13 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com