Call macro broke the called macro

Blackwater

New Member
Joined
Sep 30, 2016
Messages
12
Hello,
I have this code

Code:
Sub MakroCV()
'
' MakroCV Makro
' CV
'
' Klávesová skratka: Ctrl+Shift+A
'
    Cells.Select
    Cells.EntireColumn.AutoFit
    Range("E12").Select
    Selection.NumberFormat = "0"
    Columns("E:E").Select
    Selection.NumberFormat = "0"
    Range("E13").Select
    ActiveWindow.SmallScroll Down:=-12
    Range("A11:K11").Select
    Selection.Font.Bold = True
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorAccent3
        .TintAndShade = -0.249977111117893
        .PatternTintAndShade = 0
    End With
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorAccent3
        .TintAndShade = 0.599993896298105
        .PatternTintAndShade = 0
    End With
    Range("B12").Select
    ActiveWindow.SmallScroll Down:=0
    Columns("G:G").Select
    Selection.NumberFormat = "[$-F400]h:mm:ss AM/PM"
        Columns("K:K").Select
    Selection.NumberFormat = "0.00"
    Range("A1").Select
        Dim lastRow As Long
lastRow = Range("A5000").End(xlUp).Row
Range("A" & lastRow + 1) = "Sumár"
Range("G" & lastRow + 1).Formula = "=SUM(G11:G" & lastRow & ")"
Range("J" & lastRow + 1).Formula = "=SUM(J11:J" & lastRow & ")"
Range("K" & lastRow + 1).Formula = "=SUM(K11:K" & lastRow & ")"
Dim lr As Long, r As Long
lr = ActiveSheet.UsedRange.Rows.Count
Range("A" & lr & ":K" & lr).Interior.ColorIndex = 35
    Dim xlBook
    Set xlBook = ActiveWorkbook


    ChDir "C:\Users\00017886\Downloads\Makro\"
    ActiveWorkbook.SaveAs filename:= _
                          "C:\filepath..\" & Left(xlBook.Name, (InStrRev(xlBook.Name, ".", -1, vbTextCompare) - 1)) & ".xlsx", FileFormat:= _
                          xlOpenXMLWorkbook, CreateBackup:=False
    ActiveWorkbook.Close SaveChanges:=True
End Sub
Which works great when i run it manually. But since i have to run this one through hundrets of file, i looked up for code that will do it for me. So open the file in folder, run the macro, close open new and so on.. So i have this code for it

Code:
Sub VsetkyCV()
    Dim folderPath As String
    Dim filename As String
    Dim wb As Workbook
  
    folderPath = "C:\folder"
    
    If Right(folderPath, 1) <> "\" Then folderPath = folderPath + "\"
    
    filename = Dir(folderPath & "*.csv")
    Do While filename <> ""
      Application.ScreenUpdating = True
        Set wb = Workbooks.Open(folderPath & filename)
         
        
        Call MakroCV
        
        
        filename = Dir
    Loop
  Application.ScreenUpdating = True
End Sub

What it does however, it runs all the files, call the macro, run the macro.. but.. It will broke the document, put every table into "A" table broke the formating etc. But without the "call" macro it works great, exactly how it should. Anyone who could help me? Thanks.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,214,657
Messages
6,120,764
Members
448,991
Latest member
Hanakoro

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