Results 1 to 12 of 12

-how to use VBA to search strings and return values or cells nearby

Threaded View

  1. #1
    Registered User
    Join Date
    05-20-2009
    Location
    Wollongong,Australia
    MS-Off Ver
    Excel Vista
    Posts
    7

    -how to use VBA to search strings and return values or cells nearby

    So, think your hot stuff.

    Im needing to search through the attached document which is truck logs at a mine and use vba to search through the list for each of the different shovels eg SHVL1, SHVL2 & SHVL3, and when the code finds that string, to display the tonnage 2 colums back from it. Im about half way there a i think but am having trouble with strings, if it was numbers i could do it no problem

    I have the idea in my head but need a genius to help me with the fine print

    Heres what i have so far (that doesn't work) but it gives an idea of what i want

    Sub trucks()
    Dim a(1000) As String
    
    tonsum = 0
    
    For i = 1 To 548
    
        a(i) = Cells(i + 1, 7).Value
        
        If a(i) = "SHVL1" Then
            Range(i + 1, 5).Select
            tonsum = tonsum + ActiveCell
        End If
         Cells(1, 9).Value = tonsum
        
    Next i
    
    End Sub
    Hopefully someone konws what to do here..or has done it before
    Thanks
    Dan
    Attached Files Attached Files
    Last edited by DonkeyOte; 05-20-2009 at 03:37 AM.

Thread Information

Users Browsing this Thread

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

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