Question : Copy data from Column A to I

Hi Experts,

I would like to request Experts help. Currently the attached script able to copy Column A to C data from CH1-12 sheets into Complaints, General Section, Internal Issues, External Issues, Remark sheets. Now I need to add additional columns; Column D to I to be copied in the sheets as well. I hope Experts could help me to re-write the script. Attached together the workbook for Experts perusal.





1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
Option Explicit

Sub CompileData()
Dim rngToCompile    As Range
Dim rngArea         As Range
Dim i               As Long
Dim wksName         As String
Dim r               As Long
Dim MySheets
Dim wksCompile      As Worksheet
Dim rCell           As Range

Set wksCompile = Worksheets("Compilation")

MySheets = Array("CH1", "Ch2", "CH3", "CH4", "CH5", "CH6", "CH7", "CH8", "CH9", "CH10", "CH11", "CH12")  '< adjust sheet names here

Application.ScreenUpdating = 0
For i = LBound(MySheets) To UBound(MySheets)
    With Sheets(CStr(MySheets(i)))
        On Error Resume Next
        Set rngToCompile = .Columns(2).SpecialCells(2, 1)
        On Error GoTo 0
        If Not rngToCompile Is Nothing Then
            For Each rngArea In rngToCompile.Areas
                If Len(rngArea.Cells(1).Offset(-1, 1)) Then
                    wksName = rngArea.Cells(1).Offset(-1, 1)
                Else
                    wksName = rngArea.Cells(1).Offset(-1, -1)
                End If
                For Each rCell In rngArea
                    If ISEXIST(Sheets(CStr(Trim(wksName))).UsedRange.Columns("a:b").Value, MySheets(i) & ";" & CLng(rCell.Value)) Then GoTo Nxt
                Next
                rngArea.Offset(, -1).Resize(, 3).Copy
                With Sheets(CStr(Trim(wksName)))
                    r = .Range("a" & .Rows.Count).End(xlUp).Offset(1).Row
                    .Range("a" & r).PasteSpecial -4104
                    .Range("a" & r).Resize(rngArea.Rows.Count).Value = MySheets(i)
                End With
                With Sheets("Compilation")
                    r = .Range("a" & .Rows.Count).End(xlUp).Offset(1).Row
                    .Range("a" & r).Value = MySheets(i)
                    .Range("a" & r).Offset(1).PasteSpecial -4104
                End With
Nxt:
            Next
            Set rngToCompile = Nothing
        End If
    End With
Next
Xit:
Set wksCompile = Nothing
Set rngToCompile = Nothing
With Application
    .ScreenUpdating = 1
    .CutCopyMode = 0
End With
End Sub
Function ISEXIST(ByRef varData As Variant, ByVal strConcated As String) As Boolean
Dim strConcat As String, i As Long

ISEXIST = False
For i = 1 To UBound(varData, 1)
    On Error Resume Next
    strConcat = varData(i, 1) & ";" & CLng(varData(i, 2))
    On Error GoTo 0
    If LCase$(strConcat) = LCase$(strConcated) Then
        ISEXIST = True
        Exit Function
    End If
Next
End Function

Answer : Copy data from Column A to I

If the app uses MS Access, then you need to set IIS to allow 32-bit drivers. There is no 64-bit driver for MS-Access.
Random Solutions  
 
programming4us programming4us