mictlantecuhtli
New Member
- Joined
- Oct 25, 2021
- Messages
- 10
- Office Version
- 365
- Platform
- Windows
Hi guys, I trying to start using VBA to automatize some task at work,
I haved found a code that opened all files in a folder, and works pretty well, but now I need the following:
Delete rows 1 to 3 and 6 to 7 mantain rows 4 and 5
Then look for an specific words "MONEDA NACIONAL", on the first column and delete the entire row where those words appear
Then delete column A, J, K ,l M, N, O and P
The code I haved found, open the files and and closed saving changes, but can't delete what I need,
Pleae can you help me to achieve this task
Thank's in advanced
I haved found a code that opened all files in a folder, and works pretty well, but now I need the following:
Delete rows 1 to 3 and 6 to 7 mantain rows 4 and 5
Then look for an specific words "MONEDA NACIONAL", on the first column and delete the entire row where those words appear
Then delete column A, J, K ,l M, N, O and P
VBA Code:
Sub RunOnAllFilesInFolder()
Dim folderName As String, eApp As Excel.Application, fileName As String
Dim wb As Workbook, ws As Worksheet, currWs As Worksheet, currWb As Workbook
Dim fDialog As Object: Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
Set currWb = ActiveWorkbook: Set currWs = ActiveSheet
'Select folder in which all files are stored
fDialog.Title = "Select a folder"
fDialog.InitialFileName = currWb.Path
If fDialog.Show = -1 Then
folderName = fDialog.SelectedItems(1)
End If
'Create a separate Excel process that is invisibile
Set eApp = New Excel.Application: eApp.Visible = False
'Search for all files in folder [replace *.* with your pattern e.g. *.xlsx]
fileName = Dir(folderName & "\*.xlsx")
Do While fileName <> ""
'Update status bar to indicate progress
Application.StatusBar = "Processing " & folderName & "\" & fileName
Set wb = eApp.Workbooks.Open(folderName & "\" & fileName)
wb.Close SaveChanges:=True 'Close opened worbook w/o saving, change as needed
Debug.Print "Processed " & folderName & "\" & fileName
fileName = Dir()
Loop
eApp.Quit
Set eApp = Nothing
'Clear statusbar and notify of macro completion
Application.StatusBar = ""
MsgBox "Completed executing macro on all workbooks"
End Sub
The code I haved found, open the files and and closed saving changes, but can't delete what I need,
Pleae can you help me to achieve this task
Thank's in advanced