VBABEGINER
Well-known Member
- Joined
- Jun 15, 2011
- Messages
- 1,284
- Office Version
- 365
- Platform
- 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..
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