Excel/Find Function


Hi Sir,

Sorry sir, i just posted a question, but i got a error msg, Im not sure if that was posted or not. So writing it again.

I need your help very badly sir. I have some data  in Sheet2 and I want to find some data based on below logic and paste it in Sheet 1.

In Sheet2, I want to  find "Memory:" in Sheet2 Column A and capture next column value of it... for example if "Memory:" is present in A30, then I want the value of B30 and paste that value in Sheet 1, B2. The problem im facing is, "Memory:" at times is present in A30 at times in some other location.

Can you please help me out with it sir.

Many thanks in advance.



Is this an Excel vba request?   See code which should be placed in a general module (in the visual basic editor do Insert => Module  (I suggest a worksheet function solution at the bottom)

Sub abc()
Dim sh1 As Worksheet, sh2 As Worksheet
Dim r As Range, cell As Range

Set sh1 = Worksheets("Sheet1")
Set sh2 = Worksheets("Sheet2")
Set r = sh2.Range("A2", sh2.Cells(sh2.Rows.Count, 1).End(xlUp))
Debug.Print r.Address(0, 0, xlA1, True)
For Each cell In r
 If InStr(1, cell, "memory:", vbTextCompare) > 0 Then
   cell.Offset(0, 1).Copy sh1.Range("B2")
   Exit For
 End If
End Sub

If you wanted a worksheet function then this would do it


Tom Ogilvy

About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Tom Ogilvy


Selected as an Excel MVP by Microsoft since 1999. Answering Excel questions in Allexperts since its inception in 2001. Able to answer questions on almost all aspects of Excel's internal capabilities. If seeking a VBA solution, please specify that in your question itself so I give you the answer you want. [Excel has weak protection - if you are distributing an application, I don't answer questions on how to protect your project from your users.]


Extensive experience.

Master of Science (MS) degree Operations Research (ORSA)

Awards and Honors
Microsoft MVP in Excel.

©2016 About.com. All rights reserved.