Results 1 to 16 of 16

VBA search and retunr results - simple programming

Threaded View

  1. #1
    Registered User
    Join Date
    04-10-2017
    Location
    Southampton
    MS-Off Ver
    Office 2013
    Posts
    4

    VBA search and retunr results - simple programming

    Hi,

    I know this is probably basic programming for some of you: -) but after spending all afternoon watching youtube videos and getting
    the same error message 'For without next' and 'Cannot execute code without break' I finally give up. ;-(
    I have no training or knowledge of excel apart from as a user.

    PLEASE HELP!!!
    ok....ill keep it simple

    on sheet1 I have a search box to enter 'store number; (and a button to link to the macro).
    if a match is found on sheet2 column A (sheet 2 has 5 columns) results should be displayed back on sheet1 D6,E6,F6,G6,H6
    there is more than one entry for the same store on sheet 2 they all need to be displayed on sheet 1 and its not in order.

    this what I've tried so far.....copying a youtube video but it was design to only return one row I need all matches to be returned....
    and it didn't work anyway.

         
    Sub searchdata()
    
    Dim erow As Long
    Dim ws As Worksheet
    Dim lastrow As Long
    Dim count As Integer
    
    lastrow = Sheets("Data2").cell(Rows.count, 1).End(x1up).Row
    
    For X = 2 To lastrow
    If Sheets("Data2").cellss(X, 1) = Sheet1.Range("b4") Then
    Sheet1.Range("E6") = Sheets("data2").Cells(X, 1)
    Sheet1.Range("F6") = Sheets("data2").Cells(X, 2)
    Sheet1.Range("G6") = Sheets("data2").Cells(X, 3)
    Sheet1.Range("H6") = Sheets("data2").Cells(X, 4)
    Sheet1.Range("I6") = Sheets("data2").Cells(X, 5)
    End If
            
    End Sub
    PS. This spread sheet is for a bank and I can't upload any of the information or onto here :-(
    Last edited by renangv; 04-10-2017 at 02:27 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Simple search box column and retrive results to search box sheet
    By Tanakaka in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 01-08-2017, 08:47 AM
  2. Look up 2 coloumn and retunr the multiple values
    By kiranmayi16 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-31-2014, 02:29 PM
  3. Simple search function and results display.
    By dgbradl in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-17-2013, 06:33 PM
  4. MATCH and INDEX function retunr the same value
    By albertoro in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 01-04-2013, 10:44 PM
  5. Simple Spreadsheet programming help
    By theebookzoo in forum Excel General
    Replies: 2
    Last Post: 08-25-2008, 03:27 PM
  6. Programming a simple formula
    By anagaraj1 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 08-04-2005, 11:05 AM
  7. [SOLVED] Simple Programming Function??
    By Texins Karate in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-12-2005, 01:06 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