HELP - Copy Rows to a Single Row (One Row)

Santude

New Member
Joined
Jul 28, 2012
Messages
18
I am currently trying to copy Rows, that will change in size, to a single Row As shown below:

Sheet1 (QuoteGroup)
Item# Qty Item Price Total
GSX140361 2 $2.00 $4.00
AWUF180210 3 $5.00 $15.00
GSZH502410 4 $3.00 $12.00

Sheet2 (QuoteManagementEQ)
Item# Qty Item Price Total Item# Qty Item Price Total Item# Qty Item Price Total
GSX140361 2 $2.00 $4.00 AWUF180210 3 $5.00 $15.00 GSZH502410 4 $3.00 $12.00


I have gone through writing a couple of functions and can't get off of going back to the Transpose Function which I know is not the right way of doing it. I found the following code on-line, but is obviously wrong. I know I need to loop through each row, but I am lost...And help would be greatly appreciated!!! Again, I know the code below is completely wrong....

VBA Code:
Sub CollectRows()
   
    Dim og As Worksheet, ns As Worksheet
    Dim LastRowA As Long
    Dim LastCol As Long, LastRowC As Long, iRow As Long
   
    Set og = ThisWorkbook.Sheets("QuoteGroup")
    Set ns = ThisWorkbook.Sheets("QuoteManagementEq")

    'Dim ws As Worksheet
    'Set ws = ThisWorkbook.Worksheets("Sheet1")
   
    Const FirstCol As Long = 1 'column A is the first column with data
   
    LastRowC = og.Cells(og.Rows.Count, FirstCol).End(xlUp).Row 'find last row in col A

    For iRow = 2 To LastRowC 'run from row 2 to last row in column C
        LastRowA = og.Cells(og.Rows.Count, "A").End(xlUp).Row 'find last row in col A
        LastCol = og.Cells(iRow, og.Columns.Count).End(xlToLeft).Column 'find last column in current row

        'copy and transpose values
        ns.Cells(LastRowA, "A").Offset(RowOffset:=1).Resize(RowSize:=LastCol - FirstCol + 1).Value = _
        WorksheetFunction.Transpose(og.Cells(iRow, FirstCol).Resize(ColumnSize:=LastCol - FirstCol + 1).Value)
    Next iRow
End Sub
 
Last edited by a moderator:

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
A few that will generally make it easier for people to help you.
  1. When posting vba code in the forum, please use the available code tags. It makes your code much easier to read/debug & copy. My signature block below has more details. I have added the tags for you this time. 😊

  2. Update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

  3. Investigate XL2BB for providing sample data & expected results to make it easier for helpers to understand just what you have & where it is and also what you want & where it is to be.
 
Upvote 0

Forum statistics

Threads
1,215,073
Messages
6,122,970
Members
449,095
Latest member
Mr Hughes

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top