View Full Version : Applying formulas to certain cells
Klartigue
09-06-2011, 08:48 AM
I have this in one of my macros..
If Application.CountIf(.Range("D1").Resize(i), .Cells(i, "D").Value) = 1 Then
Is there a way to alter this macro so it says to apply this if the value does not equal "cover" [instead of having the .Celks(i, "D").Value) =1]
Thanks for the help
Bob Phillips
09-06-2011, 09:01 AM
Do you mean
If Application.CountIf(.Range("D1").Resize(i), "<>cover") = 1
Klartigue
09-06-2011, 09:10 AM
Sub evaltest()
'
' evaltest Macro
'
Windows("Bid List.xlsx").Activate
With ActiveSheet
If Application.CountIf(.Range("D1").Resize(i), "<>cover") = 1 Then
.Cells(i, "S").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-13],pricefile.xlsx!R1:R1048576,2,FALSE)"
End If
Next i
End With
End Sub
its giving me a compile error saying Next without for
Can you help me fix this?
Bob Phillips
09-06-2011, 09:33 AM
It's your code, where did it go, nothing I did removed it.
I guess you actually want
If .Cells(i, "D") <> "cover" Then
.Cells(i, "S").FormulaR1C1 = "=VLOOKUP(RC[-13],pricefile.xlsx!R:R,2,FALSE)"
End If
and you should be using VBA tags by now around your code.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.