Created
December 14, 2012 17:29
-
-
Save mbustamanteo/4287158 to your computer and use it in GitHub Desktop.
Macro para planillas Deloitte. Ingresa formulas en celdas segun color
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sub PonerFormulasPlanilla() | |
' | |
' Esta macro lo que hace es poner una formula | |
' en todas las celdas de un determinado color | |
' | |
' Recomiendo poner la formula en formato R1C1 | |
' | |
' .Color = 15986394 ' celda azul para las formulillas | |
' | |
' | |
Dim celda As Range ' la celda actual | |
Dim color As Long ' color de la celda | |
Dim colorABuscar As Long ' color de la celda que estamos buscando | |
Dim rangoAModificar As Range ' rango de los datos | |
Dim formula As String ' Formula a poner en las celdas | |
colorABuscar = 15986394 | |
Set rangoAModificar = Range("A1:AQ300") | |
formula = "=VLOOKUP(RC6,'[P&L sap.xlsx]Sheet1'!R1C1:R386C44,R5C,FALSE )" | |
Range("A1").Select | |
Application.FindFormat.Clear | |
ActiveSheet.EnableCalculation = False | |
With Application.FindFormat.Interior | |
.color = colorABuscar | |
.Pattern = xlSolid | |
.PatternColorIndex = xlAutomatic | |
End With | |
Set celda = rangoAModificar.Find(What:="", after:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ | |
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _ | |
, SearchFormat:=True) | |
If Not celda Is Nothing Then | |
firstAddress = celda.Address | |
Do | |
celda.FormulaR1C1 = formula | |
Set celda = rangoAModificar.Find(What:="", after:=celda, SearchFormat:=True) | |
Loop While Not celda Is Nothing And celda.Address <> firstAddress | |
Else | |
Debug.Print "No se ha modificado nada" | |
End If | |
ActiveSheet.EnableCalculation = True | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment