Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
PrimeraHoja.Range("A1:D10").Copy Destination:=Hoja2.Range("D1")
End Sub
3.Sub MostrarMensaje()
If MsgBox("Desea borrar definitivamente el contenido?", vbYesNo + vbQuestion) = vbYes Then PrimeraHoja.Range("A1:D10").ClearContents End If
End Sub
5.Sub ComprobarValorNumrico()
If IsNumeric(PrimeraHoja.Range("A1").Value) = True Then MsgBox ("El valor de la celda es numrico"), vbInformation Else MsgBox ("El valor de la celda no es numrico"), vbCritical End If
With PrimeraHoja.Range("A1") If .Value >= 1 And .Value <= 10 Then MsgBox "El valor est dentro de lo determinado", vbInformation Else MsgBox "El valor no est dentro de lo determinado", vbCritical End If End With
End Sub
'valor 1-10 ==> cambiar color de la celda = rojo 'valor 11-20 ==> cambiar color de la celda = verde 'de lo contrario ==> cambiar color de la celda = estndard
7.Sub CambiarColorCelda()
With PrimeraHoja.Range("A1") Select Case .Value Case 1 To 10 .Interior.ColorIndex = 3 ' rojo Case 11 To 20 .Interior.ColorIndex = 4 ' verde Case Else .Interior.ColorIndex = xlColorIndexNone ' color estndard End Select End With
For celda = 1 To 10 With PrimeraHoja.Cells(celda, 1) Select Case .Value Case 1 To 10 .Interior.ColorIndex = 3 ' rojo Case 11 To 20
.Interior.ColorIndex = 4 ' verde Case Else .Interior.ColorIndex = xlColorIndexNone ' color estndard End Select End With Next celda
End Sub
celdaMax = PrimeraHoja.UsedRange.Rows.Count
With PrimeraHoja.Cells(celda, 1) Select Case .Value Case 1 To 10 .Interior.ColorIndex = 3 ' rojo Case 11 To 20 .Interior.ColorIndex = 4 ' verde Case Else .Interior.ColorIndex = xlColorIndexNone ' color estndard
With Hoja3 For i = 1 To 56 .Cells(i, 1).Value = i .Cells(i, 2).Interior.ColorIndex = i Next i End With
MsgBox Hoja3.Range("d10").Interior.ColorIndex
End Sub
Hoja1.Select
Next celda
End Sub
For celda = 2 To celdaMax If .Cells(celda, 1).Value < 50 Then .Rows(celda).Hidden = True End If Next celda
Hoja4.Rows.Hidden = False
End Select
Next celda
End With
End Sub
For celda = 2 To celdaMax If Application.WorksheetFunction.CountIf(.Columns(1), .Cells(celda, 1).Value) > 1 Then .Cells(celda, 1).Interior.ColorIndex = 6 Else .Cells(celda, 1).Interior.ColorIndex = xlColorIndexNone
End If
Next celda
End With
Next celda
End With
End Sub
Next celda
End With
End Sub 20 Sub Buscar01() 'Buscar la palabra exacta (teniendo en cuenta maysculas y minsculas)
If .Range("B1").Value = .Cells(celda, 2).Value Then .Cells(celda, 2).Interior.ColorIndex = 20 Else .Cells(celda, 2).Interior.ColorIndex = xlColorIndexNone
End If
Next celda
End With
End Sub 21 Sub Buscar02() 'Buscar la palabra exacta (SIN tener en cuenta maysculas y minsculas)
If UCase(.Range("B1").Value) = UCase(.Cells(celda, 2).Value) Then .Cells(celda, 2).Interior.ColorIndex = 20 Else .Cells(celda, 2).Interior.ColorIndex = xlColorIndexNone
End If
Next celda
End With
End Sub
For celda = 2 To celdaMax If InStr(.Cells(celda, 2).Value, .Range("B1").Value) > 0 Then .Cells(celda, 2).Interior.ColorIndex = 4 Else .Cells(celda, 2).Interior.ColorIndex = xlColorIndexNone End If
Next celda
End With
End Sub
23 Sub Buscar04() 'Buscar una coincidencia parcial(SIN tener en cuenta maysculas y minsculas)
For celda = 2 To celdaMax If InStr(UCase(.Cells(celda, 2).Value), UCase(.Range("B1").Value)) > 0 Then .Cells(celda, 2).Interior.ColorIndex = 4 Else .Cells(celda, 2).Interior.ColorIndex = xlColorIndexNone End If
Next celda
End With
End Sub
For celda = celdaMax To 2 Step -1 If UCase(.Cells(celda, 1).Value) = "X" Then .Cells(celda, 1).Delete End If
Next celda
End With
End Sub
With Hoja10
celdaMax = .UsedRange.Rows.Count
Next celda
End With
End Sub
For celda = celdaMax To 1 Step -1 If .Cells(1, celda).Value = "" Then .Cells(1, celda).Delete End If Next celda
End With
End Sub
27.Sub PegarHojaDeClculoComienzo()
Worksheets.Add before:=Worksheets(1)
End Sub
Sub PegarHojaDeClculoFinal()
End Sub
iCant = Application.SheetsInNewWorkbook
Application.SheetsInNewWorkbook = 1
Workbooks.Add
Next i
Application.SheetsInNewWorkbook = iCant
End Sub
Sub CopiarHojaDeClculoGuardarNuevoLibro()
Hoja13.Copy ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & ActiveSheet.Name & ".xls" ActiveWorkbook.Close
End Sub
Sub CopiarHojaDeClculoGuardarNuevoLibro02()
Hoja13.Copy ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & Format(Date, "YYYY.MM.DD") & " " & ActiveSheet.Name & ".xls" ActiveWorkbook.Close
End Sub
Application.DisplayAlerts = False
Hoja.Copy ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & ActiveSheet.Name & ".xls" ActiveWorkbook.Close
Next Hoja
Application.DisplayAlerts = True
End Sub
End Sub
Next Hoja
End Sub