Ejemplos de macros en excel
' Ubicación C:\Documents and Settings\ldelgado\Application Data\Microsoft\Excel\XLSTART\personal.xlsb
Function IsOpen(FileName As String) As Boolean
Dim wb As Workbook
For Each wb In Application.Workbooks
If UCase(wb.Name) = UCase(FileName) Then
IsOpen = True
Exit Function
End If
Next wb
IsOpen = False
End Function
Subdispatcher()
'
' dispatcher Macro
' Macro grabada el 03/08/2008 por Authorized User
'
' Acceso directo: CTRL+d
'
strnombre = ActiveSheet.Parent.FullName
folio = Range("i9").Value
Fecha = Range("i6").Value
Diir = Range("f17").Value
numCliente = Range("e5").Value
Turno = Range("e9").Value
Despachador = Range("a88").Value
Capturista = Range("c97").ValueTecnico = Range("e88").Value
Clasificacion = Range("e97").Value
T1 = Range("e8").Value
T2 = Range("g25").Value
T3 = Range("g26").Value
T4 = Range("g28").Value
T6 = Range("g31").Value
Dep = Range("h97").Value
Reporto = Range("f15").Value
Prob = Range("f20").Value
sol = Range("a34").Value
open_cuu
Range("A:A").Select
WhileActiveCell.Value ""
ActiveCell.Offset(1, 0).Range("A1").Select
Wend
ActiveCell.FormulaR1C1 = folio
'ActiveCell.FormulaR1C1 = ("CUU / ") & Folio & (" / 2011")
ActiveCell.Next.Select
ActiveCell.FormulaR1C1 = Fecha
ActiveCell.Next.Select
'ActiveCell.FormulaR1C1 = dir1
ActiveCell.FormulaR1C1 = Diir'ActiveCell.Next.Select
'ActiveCell.FormulaR1C1 = num
ActiveCell.Next.Select
ActiveCell.FormulaR1C1 = numCliente
ActiveCell.Next.Select
ActiveCell.FormulaR1C1 = Turno
ActiveCell.Next.Select
ActiveCell.FormulaR1C1 = Despachador
ActiveCell.Next.Select
ActiveCell.FormulaR1C1 = Capturista
ActiveCell.Next.SelectActiveCell.FormulaR1C1 = Tecnico
ActiveCell.Next.Select
ActiveCell.FormulaR1C1 = Clasificacion
ActiveCell.Next.Select
ActiveCell.FormulaR1C1 = T1
ActiveCell.Next.Select
ActiveCell.FormulaR1C1 = T2
ActiveCell.Next.Select
ActiveCell.FormulaR1C1 = T3
ActiveCell.Next.SelectActiveCell.FormulaR1C1 = T4
ActiveCell.Next.Select
ActiveCell.FormulaR1C1 = T6
ActiveCell.Next.Select
ActiveCell.FormulaR1C1 = Dep
ActiveCell.Next.Select
ActiveCell.FormulaR1C1 = Reporto
ActiveCell.Next.Select
ActiveCell.FormulaR1C1 = Prob & " " & sol
ActiveCell.Offset(0, -14).Range("A1").Select
ActiveWorkbook.Close (True)open_Relacion_diaria
Range("folio").Select
While ActiveCell.Value ""
ActiveCell.Offset(1, 0).Range("A1").Select
Wend
'ActiveCell.FormulaR1C1 = ("CUU / ") & Folio & (" / 2011")
ActiveCell.FormulaR1C1 = folio
ActiveCell.Next.Select
ActiveCell.FormulaR1C1 = Fecha
ActiveCell.Next.Select
ActiveCell.FormulaR1C1 = Diir'ActiveCell.FormulaR1C1 = dir1
ActiveCell.Next.Select
ActiveCell.FormulaR1C1 = numCliente
'Application.Goto Reference:="DatosDia"
'selection.Sort Key1:=Range("c17"), Order1:=xlAscending, 'Header:=xlNo, _
' OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
' DataOption1:=xlSortNormal
ActiveWorkbook.Close (True)'open_strnombre
'Terminar
' Limpiar
'Etiqueta
'nueva
'Abrir_Docs
Application.ScreenUpdating = True
End Sub
Sub Terminar()
'Windows(milibro).Activate
'para activar el libro del nombre asignado
Range("A34:k41").Select
With Selection
.HorizontalAlignment = xlCenter...
Regístrate para leer el documento completo.