Macro For If Function

A

Akash

hi,

I have 6 Columns

A = Number
B = Number
C= Number
D= A x B x C
E= Input Number by user
F = If(D = E) = Matched/Unmatched)

I want a macro the value of Column D = E then it should display
Matched or Unmatched in Column F.

Is it possible.

Thanks in Advance
 
J

John Coleman

A spreadsheet formula should work: in F1 (say) enter the formula

=If(D1=E1,"Matched","Unmatched")

and copy it down for as many rows as you need. If this doesn't
suffice, explain what you need in more detail.

Hth

-John Coleman
 
A

Akash

A spreadsheet formula should work: in F1 (say) enter the formula

=If(D1=E1,"Matched","Unmatched")

and copy it down for as many rows as you need. If this doesn't
suffice, explain what you need in more detail.

Hth

-John Coleman


i require a macro for the same...

is it possible...

Akash
 
G

Guest

Right click the sheet tab and paste this in

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Application.Intersect(Target, Range("E1")) Is Nothing Then
If Target.Value = Cells(1, 4).Value Then
Cells(1, 6).Value = "Matched"
Else
Cells(1, 6).Value = "Unmatched"
End If
End If
End Sub

Mike
 
J

John Coleman

Why do you need a macro to duplicate the functionality?

Something like this could work:

Sub CheckMatches()
Dim R As Range
Dim cl As Range
Set R = Range("F1:F5")
For Each cl In R.Cells
If cl.Offset(0, -2).Value = cl.Offset(0, -1).Value Then
cl.Value = "Matched"
Else
cl.Value = "Unmatched"
End If
Next cl
End Sub

adjust the range statement to get the F-range you want. You can make
the sub more flexible by passing the range of rows as parameters

Hth

-John Coleman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top