if cell formula is ".... than run a macro if not do not

frotaru

Board Regular
Joined
Oct 12, 2006
Messages
124
Hi,

I need a macro that runs only if a certain cell has a specified formula

Something like

in any worksheet
After checking if
Range("A2").Formula = "=IF(ISERROR(VLOOKUP(R[-1]C,[Fields.xls]PDiff_Fields!R5C1:R50C2,2,FALSE)),"""",VLOOKUP(R[-1]C,[Fields.xls]PDiff_Fields!R5C1:R50C2,2,FALSE))"

if it is true is should do nothing if false run a macro

Can anyone hlp me ?

Than you
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

jindon

MrExcel MVP
Joined
Aug 21, 2004
Messages
16,995
Hi

to ThisWorkbook module

Code:
Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
If Sh.Range("A2").Value = False Then
   'YourCode Here
End If
End Sub
 

frotaru

Board Regular
Joined
Oct 12, 2006
Messages
124
:d

Thank for u're help

But ... I’m using a macro that should check if cell “A2” is already filled with the formula shown. If is not call another macro

Something like

if Range("A2").Formula = "=IF(ISERROR(VLOOKUP(R[-1]C,[Fields.xls]PDiff_Fields!R5C1:R50C2,2,FALSE)),"""",VLOOKUP(R[-1]C,[Fields.xls]PDiff_Fields!R5C1:R50C2,2,FALSE))"

than do nothing

else run sub test01



Sub test01

Rows("2:2").Select
Selection.Insert Shift:=xlDown
Range("A2").Select
ActiveCell.FormulaR1C1 = _
"=IF(ISERROR(VLOOKUP(R[-1]C,[Fields.xls]PDiff_Fields!R5C1:R50C2,2,FALSE)),"""",VLOOKUP(R[-1]C,[Fields.xls]PDiff_Fields!R5C1:R50C2,2,FALSE))"
Range("A2").Select
Selection.AutoFill Destination:=Range("A2:AX2"), Type:=xlFillDefault
Cells.Select
Range("A2").Activate
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal
Range("A1").Select


Could u help me with this ??

Plizzz
 

jindon

MrExcel MVP
Joined
Aug 21, 2004
Messages
16,995
Re: :d

Then something like
Code:
Sub sample()
Dim myFormla As String, ws As Worksheet
myFormula = "=IF(ISERROR(VLOOKUP(R[-1]C,[Fields.xls]PDiff_Fields!R5C1:R50C2,2,FALSE)),"""",VLOOKUP(R[-1]C,[Fields.xls]PDiff_Fields!R5C1:R50C2,2,FALSE))"

For Each ws In Sheets
   If ws.Range("a2").FormulaR1C1 = myFormula Then
      ws.Select
      tet01
   End If
Next
End Sub
 

frotaru

Board Regular
Joined
Oct 12, 2006
Messages
124
Hi

Hi
Thank u verry much
U're ideea guided me and i solve it

thank u again
 

Forum statistics

Threads
1,141,681
Messages
5,707,795
Members
421,528
Latest member
datdude151

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top