loop

gledister

Board Regular
Joined
Mar 21, 2011
Messages
173
imagine in column A we have this situation:
Excel Workbook
A
1W103XU13W
2ROSS
398% COTTON / 2% ELASTANE
447 FOR ALL
532
675
7W103YH17D
8ROSS
998% COTTON / 2% ELASTANE
10USED MID LIGHT
1132
1275
13W10AE124Z
14MATT
15100% COTTON
16VICENTE WORN
1764
18160
Sheet1



what we wanna do is having all these datas in this way:

Excel Workbook
BCDEFG
1W103XU13WROSS98% COTTON / 2% ELASTANE47 FOR ALL3275
2W103YH17DROSS98% COTTON / 2% ELASTANEUSED MID LIGHT3275
3W10AE124ZMATT100% COTTONVICENTE WORN64160
Sheet2



Any idea for a macro that can resolve this?

Kind regards.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Something like this?

Code:
Sub Macro1()
Dim LR As Long
Dim i As Long
Dim j As Long

    LR = Sheets(1).Range("A" & Rows.Count).End(xlUp).Row
    j = 2

For i = 2 To LR Step 7
    Range("B" & j & ":H" & j).Select
    Selection.FormulaArray = "=TRANSPOSE(R" & i & "C[-1]:R" & i + 6 & "C[-1])"
    j = j + 1
Next i
End Sub
 
Last edited:
Upvote 0
I wanna repeat this action for the whole column:

<TABLE style="WIDTH: 378pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=504><COLGROUP><COL style="WIDTH: 378pt; mso-width-source: userset; mso-width-alt: 18432" width=504><TBODY><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; WIDTH: 378pt; HEIGHT: 15pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=20 width=504>Selection.Copy</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 15pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=20> ActiveCell.Offset(0, 1).Range("A1").Select</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 15pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=20> Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 15pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=20> False, Transpose:=True</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 15pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=20> ActiveCell.Offset(6, -1).Range("A1:A6").Select</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 15pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=20> Application.CutCopyMode = False</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 15pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=20>Selection.Copy</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 15pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=20> ActiveCell.Offset(0, 1).Range("A1").Select</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 15pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=20> Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 15pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=20> False, Transpose:=True</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 15pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=20> ActiveCell.Offset(6, -1).Range("A1:A6").Select</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 15pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" height=20> Application.CutCopyMode = False

any idea?
</TD></TR></TBODY></TABLE>
 
Upvote 0
Code:
Sub Macro1()
Dim LR As Long
Dim i As Long
Dim j As Long

    LR = Sheets(1).Range("A" & Rows.Count).End(xlUp).Row
    j = 1

For i = 1 To LR Step 7
    Range("B" & j & ":H" & j).Select
    Selection.FormulaArray = "=TRANSPOSE(R" & i & "C[-1]:R" & i + 6 & "C[-1])"
    j = j + 1
Next i

    Columns("B:H").Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    Range("A1").Select
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,947
Latest member
Gerry_F

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