Codigo Macro A

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

Sub alaaa()

Dim b1 As String
Dim b2 As Variant
Dim b11 As String
Dim b111 As String

'b111 es el nombre de la carpeta donde se enviaran los archivos de


'libros de macro transformados a xlsx, si cambia ese nombre cambiar esta parte del
código.

b111 = "Archivos TMI xlsx"


b11 = ThisWorkbook.Path
MsgBox b11
b1 = ActiveWorkbook.Name
MsgBox b1

For Each hojas In ThisWorkbook.Sheets


hojas.Copy
Application.ActiveWorkbook.SaveAs Filename:=b11 & "\" & b111 & "\" & b1 & ".xlsx"
Application.ActiveWorkbook.Close False
Next

End Sub

'''''''''''''''''''''
'''''''''''''''''''''
'''''''''''''''''''''
'''''''''''''''''''''
'''''''''''''''''''''
'''''''''''''''''''''
Sub num_CH()

Dim a As Range
Dim b As Range
Dim c As Range
Dim d As Integer
Dim e As Range
Dim i As Integer

Dim aa As Range
Dim bb As Range
Dim cc As Range
Dim dd As Range
Dim ee As Range
Dim ff As Range
Dim gg As Range
Dim hh As Range
Dim dhd As Range

Set a = Range("A7")
Set b = Range("B2")
a.Select
ActiveCell.Offset(0, b - 1).Activate

respuesta = ActiveCell.Column

Set c = Selection
c.Select
Selection.End(xlToRight).Select
respuesta2 = ActiveCell.Column

d = respuesta2 - respuesta
c.Select

For i = respuesta To respuesta2


'Cells(6, i).Formula = "=Sum(E" & i & ":E15)"
'Cells(6, i).Formula = "A"
Cells(7, i).Select
Set e = Selection

'''''''''''''''''''Aca se seleccionan los rangos en los que se aplica la formula


'''''''''''''''''''Si se agregaran mas rangos, definir nueva variable y agregarla
al union

Selection.End(xlDown).Select
Range(Selection, Selection.End(xlDown)).Select
Set aa = Selection

Selection.End(xlDown).Select
Selection.End(xlDown).Select
Range(Selection, Selection.End(xlDown)).Select
Set bb = Selection

Selection.End(xlDown).Select
Selection.End(xlDown).Select
Range(Selection, Selection.End(xlDown)).Select
Set cc = Selection

Selection.End(xlDown).Select
Selection.End(xlDown).Select
Range(Selection, Selection.End(xlDown)).Select
Set dd = Selection

Selection.End(xlDown).Select
Selection.End(xlDown).Select
Range(Selection, Selection.End(xlDown)).Select
Set ee = Selection

Selection.End(xlDown).Select
Selection.End(xlDown).Select
Set ff = Selection

Selection.End(xlDown).Select
Range(Selection, Selection.End(xlDown)).Select
Set hh = Selection

Set gg = Union(aa, bb, cc, dd, ee, ff, hh)


gg.Select
Selection.FormulaR1C1 = "=SUMIFS('Excel Perfiles Tablas.xlsx'!
Tabla_Perfiles[Valor],'Excel Perfiles Tablas.xlsx'!
Tabla_Perfiles[Partidas],RC3,'Excel Perfiles Tablas.xlsx'!
Tabla_Perfiles[Fecha2],DATEVALUE(" & Chr(34) & e & Chr(34) & "),'Excel Perfiles
Tablas.xlsx'!Tabla_Perfiles[Proyecto],""Christiansen"")"
Next

c.Select
c.Offset(0, -1).Select
ActiveCell.EntireColumn.Select
Range(Selection, Selection.End(xlToLeft)).Select
numRows = Selection.Rows.Count
numColumns = Selection.Columns.Count
Selection.Offset(0, 6).Select
Selection.Resize(numRows + 0, numColumns - 6).Select
Selection.Columns.Delete Shift:=xlToLeft

'''''''''''''''''''''''''''''''''''''''''''''''''''''''
'2da parte de macro: Generar archivo xlsx a partir de archivo original xlsxm
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim b1 As String
Dim b2 As Variant
Dim b11 As String
Dim b111 As String

'b111 es el nombre de la carpeta donde se enviaran los archivos de


'libros de macro transformados a xlsx, si cambia ese nombre cambiar esta parte del
código.

b111 = "Archivos TMI xlsx"


b11 = ThisWorkbook.Path
MsgBox b11
b1 = ActiveWorkbook.Name
MsgBox b1

For Each hojas In ThisWorkbook.Sheets


hojas.Copy
Application.ActiveWorkbook.SaveAs Filename:=b11 & "\" & b111 & "\" & b1 & ".xlsx"
Application.ActiveWorkbook.Close False
Next

End Sub

You might also like