vb code in excel

W

woranan

help me please, I almost my mind. I tried to fix my problems long tim
but i cann't. so anyone should known this things.
I have one question; If i have numeric in cell on Column A 15 rows an
5 rows in Column B. Supposely i try to sort data in Column C by th
data of Column B match with Column A (row by row). How do i do to cod
in vb (on excel)?

Thank you for your kindness

Attachment filename: snag_004.jpg
Download attachment: http://www.excelforum.com/attachment.php?postid=39064
 
T

Tom Ogilvy

Sub Tester19()
Dim rngA As Range
Dim rngB As Range
Set rngA = Range(Cells(1, 1), Cells(1, 1).End(xlDown))
Set rngB = Range(Cells(1, 2), Cells(1, 2).End(xlDown))
rngA.Offset(0, 2).Formula = "=if(countif(" & rngB.Address &
",A1)>0,A1,na())"
rngA.Offset(0, 2).Formula = rngA.Offset(0, 2).Value
On Error Resume Next
rngA.Offset(0, 2).SpecialCells(xlConstants, _
xlErrors).ClearContents

End Sub
 

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

Top