Está en la página 1de 4

Funciones de Macros

para Excel.
1. Letra Negrita
2.

Funcin Selection.Font.Bold = True

4.
5.
6.
7.
8.
9.
10.
11.
12.

Sub Macro2()
'
' Macro2 Macro
'Negrita en texto'
'
Range("B4").Select
Selection.Font.Bold = True
End Sub

3.

13. Letra Cursiva


14.
15.
16.
17.
18.
19.
20.
21.
22.

Funcin Selection.Font.Italic = True


Sub Macro1()
'
' Macro1 Macro
'Para colocar Cursiva en un texto'
'
Range("B3").Select
Selection.Font.Italic = True
End Sub

23.
24. Letra Subrayada

25. Funcin Selection.Font.Underline =


xlUnderlineStyleSingle

26.
27.
28.
29.
30.
31.
32.
33.

Sub Macro3()
'
' Macro3 Macro
'subrayar un texto'
'
Range("B5").Select
Selection.Font.Underline =
xlUnderlineStyleSingle
34. End Sub

35.
36. Centrar Texto
37. Funcin .HorizontalAlignment =
xlCenter

38.

39. Sub Macro4()


40. ' Macro4 Macro
41. 'Centrar un texto'
42.
Range("B6").Select
43.
With Selection
44.
.HorizontalAlignment =
xlCenter
45.
.VerticalAlignment = xlBottom
46.
.WrapText = False
47.
.Orientation = 0

48.
49.
50.
51.
52.
53.

.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
54. End Sub

55.
56. Alinear a la izquierda
57. Funcin .HorizontalAlignment = xlLeft

58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.

Sub Macro5()
' Macro5 Macro
'derecho un texto'
Range("B7").Select
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End Sub

75.
76. Alinear a la Derecha
77. Funcin .HorizontalAlignment = xlRight

78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.

Sub Macro7()
' Macro7 Macro
'Derecho'
Range("B8").Select
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End Sub

95.
96. Tipo de Letra(Fuente)
97. Funcin:.Font .Name =

98.

99. Sub Macro8()


100.
'Cambiar fuente
101.
Range("B9").Select
102.
With Selection.Font
103.
.Name = "Arial"
104.
.Size = 11
105.
.Strikethrough = False
106.
.Superscript = False
107.
.Subscript = False
108.
.OutlineFont = False
109.
.Shadow = False
110.
.Underline =
xlUnderlineStyleNone
111.
.ThemeColor =
xlThemeColorLight1
112.
.TintAndShade = 0
113.
.ThemeFont =
xlThemeFontNone
114.
End With
115.
End Sub

116.
Tamao de Letra(Tamao
de Fuente)
117.
Funcin Selection.Font .Size =
118.
119.
120.
121.
122.
123.

Sub Macro9()
' Macro9 Macro
'tamanodefuente
Range("B9").Select
Selection.Font.Size = 12
End Sub

124.

Copiar

125.

126.

Funcin: Selection.Copy

127.
128.
129.
130.
131.
132.

Sub Macro10()
' Macro10 Macro
'copiar
Range("B10").Select
Selection.Copy
End Sub

133.

Pegar

134.

Funcin ActiveSheet.Paste

135.
136.
137.
138.
139.
140.

141.
142.
143.

144.
145.
146.
147.
148.
149.
150.

Sub Macro12()
' Macro12 Macro
'pegar
Range("E4").Select
ActiveSheet.Paste
End Sub

Cortar

Funcin Selection.Cut
Sub Macro13()
' Macro13 Macro
cortar
Range("E4").Select
Selection.Cut
End Sub

151.
152.
153.
154.
155.
156.

157.

Ordenar Ascendente

158.
Funcin
Order1:=xlAscending,
Header:=xlGuess

159.
Sub Macro14()
160.
' Macro14 Macro
161.
'ordenar de menor a mayor'
162.
Range("E7:E11").Select
163.
ActiveWorkbook.Worksheets("Hoja1"
).Sort.SortFields.Clear
164.
ActiveWorkbook.Worksheets("Hoja1"
).Sort.SortFields.Add
Key:=Range("E7"), _
165.
SortOn:=xlSortOnValues,
Order:=xlAscending,
DataOption:=xlSortNormal
166.
With
ActiveWorkbook.Worksheets("Hoja1"
).Sort
167.
.SetRange
Range("E7:E11")
168.
.Header = xlNo
169.
.MatchCase = False
170.
.Orientation =
xlTopToBottom
171.
.SortMethod = xlPinYin
172.
.Apply
173.
End With
174.
End Sub
175.

176.

Orden Descendente

177.
Order1:=xlDescending,
Header:=xlGuess
178.
Sub Macro15()
179.
' Macro15 Macro
180.
'de mayor a menor'
181.
Range("E7:E11").Select
ActiveWorkbook.Worksheets("Hoja1"
).Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Hoja1"
).Sort.SortFields.Add
Key:=Range("E7"), _
182.
SortOn:=xlSortOnValues,
Order:=xlDescending,
DataOption:=xlSortNormal
183.
With
ActiveWorkbook.Worksheets("Hoja1"
).Sort

184.
.SetRange
Range("E7:E11")
185.
.Header = xlNo
186.
.MatchCase = False
187.
.Orientation =
xlTopToBottom
188.
.SortMethod = xlPinYin
189.
.Apply
190.
End With
191.
End Sub
192.
193.
194.
195.
196.
197.
198.
199.
200.
201.
202.

223.
Funcin:
Selection.EntireRow.Delete

203.

237.
' Macro19 Macro
238.
Columns("F:F").Select
239.
Selection.Insert
Shift:=xlToRight,
CopyOrigin:=xlFormatFromLeftOrAb
ove
240.
End Sub
241.

Buscar

204.
Cells.Find(What:="Csar",
After:=ActiveCell, LookIn:=xlFormulas,
LookAt:=xlPart,
SearchOrder:=xlByRows,
SearchDirection:=xlNext, MatchCase:=
_ False).Activate

205.

206.
Sub Macro16()
207.
' Macro16 Macro
208.
'buscar
209.
Cells.Find(What:="e",
After:=ActiveCell,
LookIn:=xlFormulas, LookAt:= _
210.
xlPart,
SearchOrder:=xlByRows,
SearchDirection:=xlNext,
MatchCase:=False _
211.
,
SearchFormat:=False).Activate
212.
End Sub

213.
214.

Insertar Fila

215.
Funcin.
Selection.EntireRow.Insert

216.
Sub Macro18()
217.
' Macro18 Macro
218.
Rows("20:20").Select
219.
Selection.Insert
Shift:=xlDown,
CopyOrigin:=xlFormatFromLeftOrAb
ove

220.
221.
222.

End Sub

Eliminar Fila

224.
Sub Macro17()
225.
' Macro17 Macro
226.
Rows("2:2").Select
227.
Selection.Delete
Shift:=xlUp
228.
End Sub

229.
230.
231.
232.
233.
234.

Insertar Columna

235.
Funcin.
Selection.EntireColumn.Insert
236.
Sub Macro19()

242.

243.
te

Eliminar Columna

Selection.EntireColumn.Dele

244.
Sub Macro20()
245.
' Macro20 Macro
246.
Columns("G:G").Select
247.
Selection.Delete
Shift:=xlToLeft
248.
End Sub

249.
250.
251.

Agrandar la columna
Funcin: ColumnWidth

252.
253.
Sub Macro23()
254.
' Macro23 Macro
255.
Columns("F:F").ColumnWidth = 24
256.
End Sub

257.
258.
259.

Grabar un Libro

260.
Funcin:
ActiveWorkbook.SaveAs Filename
261.
Sub Macro24()
262.
ChDir
"C:\Users\Usuario\Documents\Semes
tre 2\Hojas electronicas"

263.
ActiveWorkbook.SaveAs
Filename:= _
264.
"C:\Users\Usuario\Documents\Semes

267.

tre 2\Hojas
electronicas\Libro1.xlsm", _
265.
FileFormat:=xlOpenXMLWorkbookMa
croEnabled, CreateBackup:=False
266.
End Sub

También podría gustarte