Urgent--macro for transposing data

HUZZAIN

New Member
Joined
Jan 25, 2016
Messages
8
Hi there,

Im trying to create a Macro which can do the following: Start selecting from a1 till blank column and coming down till blank row cell by cell , select the all above values, copy them and paste them by transposing them AFTER tWo blank columns, carry on doing this procedure and pasting the transposed values . Can you please help me with this Macro. Help will be greatly appreciated.
eg;
columnA columnB blank column blank column

<colgroup><col width="64" span="5" style="width: 48pt;"></colgroup><tbody>
</tbody>
Demir (Serum)16
Demir bağlama kapasitesi362
Glukoz 109
HBA1C5,6
Demir (Serum)41
Demir bağlama kapasitesi215
Ferritin 56,46
Glukoz 101
HBA1C5,8

<colgroup><col><col></colgroup><tbody>
</tbody>

transpose the data to 2nd blank column .
help will be greatly apppreciated.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
If I understand what you need to do, this code should work

Code:
Sub Transpose()


Dim rData As Range


Set rData = ActiveSheet.Range("A1", Cells(Rows.Count, "B").End(xlUp))


rData.Copy


ActiveSheet.Range("E1").PasteSpecial Transpose:=True


End Sub
 
Upvote 0
thankyou for the reply but the code is giving an error on the following line ,
ActiveSheet.Range("E1").PasteSpecial Transpose:=True
my excel is in different language,its saying that the selection is not matching the paste area.
 
Upvote 0
ı guess the code is selecting whole data and transposing it thats y its giving an error of not getting the space to transpose.
suppose ı have the following data .
1 j
2 f
4 f
5 g

7 jj
8 kk
9 kk
3 uu

4 ll
6 uu
7 oo

what i want the code to do is to transpose data like below
1 2 3 5
j f f g

ı want it to copy in the column d,e,f,g,h etc with their respective value.
 
Upvote 0
Try this:
Code:
Sub Huzzain()
Dim lrow As Integer
Dim lcolumn As Integer

lrow = Cells(Rows.Count, 1).End(xlUp).Row
Range("A1:B" & lrow).Copy

Cells(1, 4).PasteSpecial Transpose:=True

Nexti:
lcolumn = Cells(1, Columns.Count).End(xlToLeft).Column

For i = 4 To lcolumn
    If Cells(1, i) = "" Then
        Columns(i).Delete
        i = i - 1
        GoTo Nexti
    End If
Next i


End Sub
 
Last edited:
Upvote 0
Thanks but i didnt work its taking all the data and transposing it
1 j
2 f
4 f
5 g

7 jj
8 kk
9 kk
3 uu

4 ll
6 uu
7 oo

what i want the code to do is to transpose data like below

1 2 3 5

j f f g

7 8 9 3
jj kk kk uu


 
Upvote 0
Perhaps
Code:
Sub test()
    Dim oneArea As Range
    Dim oneValueSet As Variant
    Dim maxCol As Long, i As Long
    
    With Range("A:A")
        For Each oneArea In .SpecialCells(xlCellTypeConstants).Areas
            With oneArea.CurrentRegion
                If maxCol < .Rows.Count Then maxCol = .Rows.Count
                oneValueSet = .Value
                .ClearContents
                .Resize(.Columns.Count).Insert
                With .Offset(-.Columns.Count, 0)
                    .Resize(.Columns.Count, .Rows.Count).Value = Application.Transpose(oneValueSet)
                End With
            End With
        Next oneArea
        
        For i = .Cells(.Rows.Count, 1).End(xlUp).Row To 2 Step -1
            With Cells(i, 1)
                If .Value & .Offset(-1, 0) = vbNullString Then
                    .Resize(1, maxCol).Delete
                End If
            End With
        Next i
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,116
Messages
6,128,931
Members
449,480
Latest member
yesitisasport

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