Posts by mylai

    Re: VBA - importing all excel files from subfolders


    When I merge multiple workbooks from different sub folder by using below code, the header gets repeated, e.g column A1 to AQ15. How do I remove the header and merge only the data file.

    Sub M_snb() sn=filter(split(Createobject("").exec("cmd /c Dir ""G:\OF\*.xls"" /b/s").stdout.readall,vbcrlf),":")

    For j=0 To UBound(sn)
    With getobject(sn(j)).sheets(1).usedrange
    .Parent.parent.close 0
    End With
    End Sub

    Hi, I have VB Coding as below but the problem is when I using below code , it disable other functions as well - Format Cells, Column Width , Hide, Unhide and freeze panes. Is there any solution to disable column function only by using VB code for all worksheets in all workbooks in one folder?

    [COLOR=#333333]Private Sub Workbook_SheetActivate(ByVal Sh As Object)[/COLOR]
    [COLOR=#333333]ActiveSheet.Protect AllowInsertingColumns:=False, _[/COLOR]
    [COLOR=#333333]AllowInsertingRows:=True, _[/COLOR]
    [COLOR=#333333]AllowDeletingColumns:=True, _[/COLOR]
    [COLOR=#333333]End Sub[/COLOR]