Announcement

Collapse
No announcement yet.

Extract columns VBA

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Extract columns VBA



    Hi, This macro help to extract columns which is marked by x letter on row 1 but its only copy the data without format. How can I change the code to keep the format from OUT_COMBINED sheet after extracting data to EXPORT sheet? Pls help me with this matter, Thank you.
    Code:
    Sub getColumn_outstanding()
        Dim sArr(), dArr(), i As Long, J As Long, K As Long, c As Long, N As Long
        Application.DisplayAlerts = False
        With Sheets("OUTS_COMBINED")
            c = .Range("A2").End(xlToRight).Column
            sArr = .Range("A1", .Range("A2").End(xlDown)).Resize(, c).Value '.Resize(, c).Value
        End With
        ReDim dArr(1 To UBound(sArr), 1 To c)
        For J = 1 To c
            If sArr(1, J) <> Empty Then
                N = N + 1
                For i = 2 To UBound(sArr)
                    dArr(i - 1, N) = sArr(i, J)
                Next i
            End If
        Next J
        With Sheets("EXPORT")
            .Range("A2").Resize(1000, 100).ClearContents
            If N Then
                .Range("A2").Resize(i - 1, N) = dArr
                MsgBox "Done", , "getColumn_outstanding"
            Else
                MsgBox "Please enter x lettle above title row", , "getColumn"
            End If
        End With
        Sheets("EXPORT").Select
        Application.DisplayAlerts = True
    End Sub
    Attached Files

  • #2
    What format want you keep

    Comment


    • #3
      Hi graha_karya,

      I want to keep the same format from OUTS_COMBINED sheet to EXPORT sheet.

      Comment


      • #4


        Hi expert,

        Pls help me with this matter. Thanks in advance.

        Comment

        Working...
        X