Macro to transpose based on what is in the cell

googlesheet

New Member
Joined
Jun 10, 2015
Messages
2
Hello!
I'd like to transpose in bulk from this format :
41950
Eve
eva-me@hotmail.de
Eva-
Ku
41949
greg1
gregoire@gmail.com
Gregoire
Mor
41948
At
john@live.com
Jon
Att

<colgroup><col style="width: 100px"></colgroup><tbody>
</tbody>


to this :
41943Gnodaniel@gmail.comKa LeLai
41942Jorgejorg;e@hotmail.comJorgeGelt
41941mremik.@outlook.comMichaelRemi
41940plaa@spb.orgJuliaPlavins

<colgroup><col style="width: 100px"><col width="100"><col width="100"><col width="100"><col width="100"></colgroup><tbody>
</tbody>


If you could give me a function for this in excel or google sheet javascript format this would be great!
Thank you very much
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Hi Google,

Welcome to the board!

Try the following sample in a standard module:

Code:
Public Sub Test()

Dim oCell As Range
Dim oTarget As Range
Dim oTranspose As Range

Set oTarget = ActiveSheet.Range("A1:A" & ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row)
Set oTranspose = ActiveSheet.Range("B1")

For Each oCell In oTarget

    oTranspose.Value = oCell.Value
    
    If Val(oCell.Offset(1, 0).Value) <> 0 Then
        Set oTranspose = oTranspose.Offset(1, ((oTranspose.Column - 2) * -1))
    Else
        Set oTranspose = oTranspose.Offset(0, 1)
    End If
    
Next oCell

End Sub
 
Upvote 0
Hi Google,

Welcome to the board!

Try the following sample in a standard module:

Code:
Public Sub Test()

Dim oCell As Range
Dim oTarget As Range
Dim oTranspose As Range

Set oTarget = ActiveSheet.Range("A1:A" & ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row)
Set oTranspose = ActiveSheet.Range("B1")

For Each oCell In oTarget

    oTranspose.Value = oCell.Value
    
    If Val(oCell.Offset(1, 0).Value) <> 0 Then
        Set oTranspose = oTranspose.Offset(1, ((oTranspose.Column - 2) * -1))
    Else
        Set oTranspose = oTranspose.Offset(0, 1)
    End If
    
Next oCell

End Sub

Hmmm how can I say .....

YOU ROCK !!! YOU ARE THE MAN!!!

THANK YOU SO MUCH I could never do it without you!!!
 
Upvote 0

Forum statistics

Threads
1,215,640
Messages
6,125,974
Members
449,276
Latest member
surendra75

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