Need looping in sheets and columns..

Status
Not open for further replies.

VBABEGINER

Well-known Member
Joined
Jun 15, 2011
Messages
1,284
Office Version
  1. 365
Platform
  1. Windows
Hi All,
Starting new thread.

There are (now) 7 sheets of data.
Every sheet data contains monthly numbers.

Till col A to F are fix.

From col G onward..

Col G = Jan 18
Col H = Feb 18
Col I = Mar 18
Col J = Apr 18
Col K = YTD 2018 ....(next month col K will be May 18)
Col L = Comments....(next month col L will be YTD 2018)




I want copy data in new sheet "combine". Monthly below to every month.

For example,
Sheet1 data Jan 18
Sheet2 data Jan 18
Sheet3 data Jan 18
Sheet4 data Jan 18
Sheet5 data Jan 18
Sheet6 data Jan 18
Sheet7 data Jan 18

Sheet1 data Feb 18
Sheet2 data Feb 18
Sheet3 data Feb 18
.
.
.
and so on...


Pls help and guide me..

below is my code..
Code:
Sub fnCombine()
Dim i As Long, j As Long, LC As Integer
Dim ws As Worksheet
Dim x As Integer, z As Integer


Application.ScreenUpdating = False
Application.DisplayAlerts = False


Sheets.Add(After:=Sheets(Sheets.Count)).Name = "Combine"
For Each ws In ThisWorkbook.Sheets
    If ws.Name = "Combine" Then
    Else
        ws.Activate
        i = Range("F" & Rows.Count).End(xlUp).Row
        LC = Cells(1, Columns.Count).End(xlToLeft).Column
        If ws.Index = 1 Then
            Range("A1:G" & i).Select
            Selection.Copy
            Worksheets("Combine").Select
            Range("A1").Select
            ActiveSheet.Paste
        Else
        Range("A2:G" & i).Select
        Selection.Copy
        Worksheets("Combine").Select
        j = Range("F" & Rows.Count).End(xlUp).Row
        Range("A" & j + 1).Select
        ActiveSheet.Paste
        Application.CutCopyMode = False
        End If
    End If
Next


    


    x = Sheets.Count
    
    For z = Range("H") To LC
    
    If x.Index = 1 Then
        Range("H2:H" & i).Select
        Selection.Copy
    
    
    End If
    
    Next z




Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Duplicate https://www.mrexcel.com/forum/excel-questions/1055267-need-code.html#post5068276

Please do not post the same question multiple times. All clarifications, follow-ups, and bumps should be posted back to the original thread.
Per forum rules, posts of a duplicate nature will be locked or deleted (rule 12 here: Forum Rules).

If you do not receive a response, you can "bump" it by replying to it again, though we advise you to wait 24 hours before doing and not to bump a thread more than once a day.

 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

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