Blackwater
New Member
- Joined
- Sep 30, 2016
- Messages
- 12
Hello,
I have this code
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
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.
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
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.