Results 1 to 4 of 4

Amend Macro to use data in current cell as the search criteria..

Threaded View

  1. #1
    Registered User
    Join Date
    08-11-2009
    Location
    Lancashire England
    MS-Off Ver
    Excel 2007
    Posts
    34

    Amend Macro to use data in current cell as the search criteria..

    Hi

    I have a new macro which is great! However I also need a different version.

    I want to click on cell containing 'Ref No', activate macro, and macro use the cell content as the data, and doesn't use the "Enter Reference Number" box?

    Thank you...

    Formula: copy to clipboard
    Sub Find_Ref_Number()

    Dim strRefNum As String, rngFound As Range, rngShtName As Range

    strRefNum = Application.InputBox("Enter Reference Nummber", "Search for Reference Number", Type:=2)
    If strRefNum = "False" Then Exit Sub 'User Canceled

    'Look through sheets list on Sheet("Locations")
    For Each rngShtName In Sheets("Locations").Range("A10", Sheets("Locations").Range("A" & Rows.Count).End(xlUp))

    'Search for Ref Number on each sheet in list
    Set rngFound = Sheets(rngShtName.Value).Cells.Find(What:=strRefNum, _
    LookIn:=xlValues, _
    LookAt:=xlWhole, _
    SearchOrder:=xlColumns, _
    SearchDirection:=xlNext, _
    MatchCase:=False)
    'If found, go to match
    If Not rngFound Is Nothing Then
    Application.Goto rngFound, Scroll:=True
    rngFound.Resize(9, 6).Offset(-1, -5).Select
    Exit For
    End If

    Next rngShtName

    'If no match found on any sheet, display message
    If rngFound Is Nothing Then MsgBox strRefNum, vbExclamation, "No Match Found"

    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. amend macro to select all but last column of data
    By MichPr in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-12-2014, 03:16 PM
  2. [SOLVED] Macro code to amend the status of a cell to be a date
    By katieshields in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-31-2014, 10:00 AM
  3. Replies: 4
    Last Post: 01-08-2013, 12:37 PM
  4. Macro to analyze and amend Data
    By Tao_ in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-10-2012, 11:16 AM
  5. Macro to search sheet for certain criteria and copy specific data to cell
    By ThaGonz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-02-2012, 12:34 PM
  6. Amend macro to prompt for file name/path of source data
    By dshilan in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-13-2012, 06:12 AM
  7. User form that can search and amend
    By nods in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-10-2010, 01:53 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1