Professional Documents
Culture Documents
Codigo
Codigo
MsgBox "Ingrese los archivos de Entregas y Retiros,CMg y Rentas COES del Mes"
Dim book As Object
Application.ScreenUpdating = False
'Definir la variable como tipo Variante
Dim X As Variant
'Abrir cuadro de dialogo
X = Application.GetOpenFilename _
("Excel Files (*.xlsx*,*.xlsm*), *.xlsx*,*.xlsm*", 2, "Abrir
archivos", , True)
'Validar si se seleccionaron archivos
If IsArray(X) Then ' Si se seleccionan
For i = LBound(X) To UBound(X)
Workbooks.Open X(i)
pos1 = 1
colEyR = 0
Do
Sheets(1).Activate
celda1 = Sheets(1).Cells(1, pos1)
If (celda1 <> "") Then
colEyR = colEyR + 1
End If
pos1 = pos1 + 1
Loop Until (celda1 = "")
'Renombramos variable
ncolEyR = colEyR
pos2 = 1
filEyR = 0
Do
Sheets(1).Activate
celda2 = Sheets(1).Cells(pos2, 1)
If (celda2 <> "") Then
filEyR = filEyR + 1
End If
pos2 = pos2 + 1
Loop Until (celda2 = "")
'Renombramos variable
nfilEyR = filEyR
ActiveWorkbook.Close
pos3 = 1
colCMgC = 0
Do
Sheets("Cmg_Cong").Activate
celda3 = Sheets("Cmg_Cong").Cells(1, pos3)
If (celda3 <> "") Then
colCMgC = colCMgC + 1
End If
pos3 = pos3 + 1
Loop Until (celda3 = "")
'Renombramos variable
ncolCMgC = colCMgC
pos4 = 1
filCMgC = 0
Do
Sheets("Cmg_Cong").Activate
celda4 = Sheets("Cmg_Cong").Cells(pos4, 1)
If (celda4 <> "") Then
filCMgC = filCMgC + 1
End If
pos4 = pos4 + 1
Loop Until (celda4 = "")
'Renombramos variable
nfilCMgC = filCMgC
ActiveWorkbook.Close
pos5 = 11
filRenta = 0
'Contamos las filas
Do
Sheets("Renta").Activate
celda5 = Sheets("Renta").Cells(pos5, 1)
If (celda5 <> "") Then
filRenta = filRenta + 1
End If
pos5 = pos5 + 1
Loop Until (celda5 = "")
'Renombramos variable
nfilRenta = filRenta
For k = 1 To nfilRenta
DatosRenta(k) = Sheets("Renta").Cells(10 + k, 2).Value +
Sheets("Renta").Cells(10 + k, 3).Value
Next
ActiveWorkbook.Close
End If
Next
End If
ThisWorkbook.Activate
Dim nsheets As Integer
For nsheets = 1 To 5
If nsheets = 1 Then
Sheets("R").Activate
Call limpiador
Application.ScreenUpdating = False
End Sub
Sub limpiador()
pos = 1
bus = 0
Do
celda = Cells(2, pos)
If (celda <> "") Then
bus = bus + 1
End If
pos = pos + 1
Loop Until (celda = "")
nbus = bus
End Sub