Consulting

Results 1 to 3 of 3

Thread: Please help spot the error!!!

  1. #1
    VBAX Newbie
    Joined
    Jun 2014
    Posts
    1
    Location

    Please help spot the error!!!

    I am trying to write a very simple code. I want to search through a large database by Company Names. I my sheet labeled "search" I have a search box and I want to be able to use that value to search through the database and bring back the entire row for all companies matching that name. I know I have the correct code below but there seems to be a bug in it. I have been stumped for 3 days now and would really appreciate some help!!!

    Sub finddata()
    
    
    Dim Companyname As String
    Dim finalrow As Integer
    Dim i As Integer
    
    
    Sheets("search").Range("a5:a100").ClearContents
    
    
    Companyname = Sheets("Search").Range("a2").Value
    finalrow = Sheets("Universe").Range("a3000").Row
    
    
    For i = 2 To finalrow
        If Sheets("universe").Cells(i, 10) = companyname Then
        Range(Cells(i, 1), Cells(i, 41)).Select
        Selection.Copy
        Sheets("search").Select
        ActiveSheet.Range("a100").end(xlup).Offset(1, 0).Paste
        
        
            
        End If
    
    
    Next i
    
    
    
    
    
    
        
    End Sub
    Last edited by Rstaub; 06-26-2014 at 05:52 AM.

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,638
    Please wrap the code in code tags !

  3. #3
    Just at first glance, and without testing the code... I've spotted the following.

    ActiveSheet.Range("a100").endxl(up).Offset(1, 0).Paste
    endxl(up) should be end(xlup) - Inside the brackets.

Tags for this Thread

Posting Permissions

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