+ Reply to Thread
Results 1 to 4 of 4

Add find function or vlookup in macro

  1. #1
    Registered User
    Join Date
    05-09-2012
    Location
    new york, new york
    MS-Off Ver
    Excel 2003
    Posts
    2

    Add find function or vlookup in macro

    I want to change this code so if the values of sheet1 are in, for example "row36" instead of the corresponding row of sheet2, it will still place values in that row.

    ex:
    sheet1
    row 1
    row 2
    row 3
    ...

    sheet2
    row 36
    row 4
    row 25
    ...etc...
    Please Login or Register  to view this content.
    Last edited by johndenver120; 05-09-2012 at 03:48 PM. Reason: name change

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486

    Re: Add find function or vlookup in macro

    Supplying a sample workbook may get you better results.

  3. #3
    Forum Contributor
    Join Date
    03-21-2012
    Location
    Ho Chi Minh city
    MS-Off Ver
    Excel 2003
    Posts
    180

    Re: You can refer to this file

    PHP Code: 
    Option Explicit
    Sub FindAndAdd
    ()
     
    Dim Sh As WorksheetRng As RangesRng As RangeCls As Range
     Dim MyAdd 
    As String
     
     Sheets
    ("S2").Select
     Set Sh 
    ThisWorkbook.Worksheets("S1")
     
    Set Rng Sh.Range(Sh.[a1], Sh.[a1].End(xlDown))
     For 
    Each Cls In Range([a1], [a1].End(xlDown))
        
    Set sRng Rng.Find(Cls.Value, , xlFormulasxlWhole)
        If 
    Not sRng Is Nothing Then
            MyAdd 
    sRng.Address
            
    Do
                If 
    Cls.Offset(, 1).Value sRng.Offset(, 2).Value Then
                    Cls
    .Interior.ColorIndex 35
                    Sh
    .Cells(sRng.Row"AI").Value Cells(Cls.Row"F").Value
                    Sh
    .Cells(sRng.Row"AE").Value Cells(Cls.Row"E").Value
                    Sh
    .Cells(sRng.Row"AA").Value Cells(Cls.Row"D").Value
                    Sh
    .Cells(sRng.Row"w").Value Cells(Cls.Row"C").Value
                End 
    If
                
    Set sRng Rng.FindNext(sRng)
            
    Loop While Not sRng Is Nothing And sRng.Address <> MyAdd
        End 
    If
     
    Next Cls
     Sh
    .Select:                             Set Sh Nothing
    End Sub 

    /-(ope this help.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    05-09-2012
    Location
    new york, new york
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: You can refer to this file

    Perfect!!! So happy! Thank you!!!

+ Reply to Thread

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