Transpose VBA not working

devj364

New Member
Joined
Apr 30, 2018
Messages
4
Hello All,

I am having an issue with this little piece of code. For some reason it is only transposing the information every other line and has been driving me crazy. I am still pretty new to VBA, so any help would be greatly appreciated.
Code:
Dim numrows As Integer
Dim counter As Integer
Dim x As Integer
Dim y As Integer
Dim trans As Integer


numrows = Range("A11", Range("A1").End(xlDown)).Rows.Count


Range("A11:D11").Select


counter = 1
 
    Do Until x = numrows
    trans = counter * 4
    
        counter = counter + 1
        Application.CutCopyMode = True
        Selection.Copy
        ActiveCell.Offset(1, 0).Select
        Range(Cells(Selection.Row, 1), Cells(Selection.Row, 4)).Select


            Application.Wait Now + #12:00:01 AM#
       
            
            Range("g9:g12").Offset(trans, 0).PasteSpecial Transpose:=True


            x = x + 1
    




Application.Wait Now + #12:00:01 AM#


Loop


End Sub
Thank you in advance.
 
Last edited by a moderator:

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
You haven't said what you are trying to do, but looking at your code , I think you are trying to get columns ( A to D) inot one column (G)
this code will do that for you and it is using variant arrays so it will be much much faster than the way you are doing it.

Code:
Sub test()
numrows = Cells(Rows.Count, "A").End(xlUp).Row


inarr = Range("A1:D" & numrows)
Range("G9:G" & 4 * (numrows - 10)) = ""
outarr = Range("G9:G" & 10 + 4 * (numrows - 10))
indi = 1
For i = 11 To numrows
  For j = 1 To 4
    outarr(indi, 1) = inarr(i, j)
    indi = indi + 1
  Next j
Next i
Range("G9:G" & 10 + 4 * (numrows - 10)) = outarr


End Sub
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,620
Latest member
dsubash

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