TRICKY ONE : copy data from rows !!

wetdrought

New Member
Joined
Aug 8, 2014
Messages
1
what data i have?
• Row "1" of sheet 1 is full of data in each cell.

what i want to do?
Step 1: I want to copy six colums from row 1 ( i.e. data in cells A1:F1) and paste in sheet 2 row A1:F1.
Step 2: I want to copy next six colums from row 1 ( i.e. data in cells G1:L1) and paste in sheet 2 row A2:F2. and so on till all data from the row "1" is copied.


Please Help!!!

Thanks,
wetdrought.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Code:
Sub WetDrought()
    lastcol = Sheets("Sheet1").Range("A1").End(xlToRight).Column
    For i = 1 To lastcol - 5 Step 6
        Sheets("Sheet1").Range(Cells(1, i), Cells(1, i + 5)).Copy
        With Sheets("Sheet2")
        .Select
        sh2lr = .Cells(Rows.Count, 1).End(xlUp).Row + 1
        .Range("A" & sh2lr).Select
        ActiveSheet.Paste
        End With
        Sheets("Sheet1").Select
    Next i
End Sub
I think this will work for you.
 
Upvote 0
This is not tested:

Code:
Sub testFirst()
Dim i
Dim LastColumn
Dim ws As Worksheet, targetSheet As Worksheet


Set ws = ThisWorkbook.Sheets(1)


LastColumn = ws.Cells(1, Columns.Count).End(xlToLeft).Column


For i = 1 To LastColumn


    StartColumn = i


    If StartColumn + 5 <= LastColumn Then
    
        Set targetSheet = ThisWorkbook.Sheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))


        ws.Cells(1, StartColumn).Resize(1, 6).Copy Destination:=targetSheet.Cells(1, 1)
        
        i = i + 5
    
    ElseIf StartColumn + 5 > LastColumn Then
    
        Set targetSheet = ThisWorkbook.Sheets.Add(After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count))


        ws.Cells(1, StartColumn).Resize(1, 1 + (LastColumn - StartColumn)).Copy _
        Destination:=targetSheet.Cells(1, 1)
        
        Exit For
        
    End If
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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