Results 1 to 4 of 4

Macro to update table based on multiple conditions

Threaded View

  1. #1
    Registered User
    Join Date
    07-06-2013
    Location
    Florida
    MS-Off Ver
    Excel 2010
    Posts
    12

    Macro to update table based on multiple conditions

    The following code looks at a data table ("Emp Data Behav Comp"), matches column ("V3:V7") and row ("U3:U7") and then pastes values from Activesheet range ("W3:W7"). The problem that I can't figure out is that it finds the columns but only pastes the first value from ("W3") into each cell. I need it to post each of the corresponding values("W3:W7") into the appropriate cells.

    See attached example.

    Test1.xlsx


    Any help would be appreciated.



    Sub CopytoEmpDataBehavComp()
    
    Dim ws1 As Worksheet:   Set ws1 = ActiveSheet
    Dim ws2 As Worksheet:   Set ws2 = Sheets("Emp Data Behav Comp")
    Dim rCell As Range, rDateFind As Range, RValueFind
    Dim rval As Range
    
    
    Dim strFound As String, strNotFound As String
    Dim LC1 As Long, LC2 As Long
    
    
    Set rvall = ws1.Range("V3:V7")
    Set rCell = ws1.Range("U3")
    
    strFound = vbNullString
    strNotFound = vbNullString
    
    LC2 = ws2.Cells(1, Columns.Count).End(xlToLeft).Column
    
    For Each rvall In ws1.Range("V3:V7")
    
    Set RValueFind = ws2.Range("A2:A33").Find(What:=rCell, LookIn:=xlValues, LookAt:=xlWhole)
            If Not RValueFind Is Nothing Then
            strFound = strFound & ", " & rCell
            Set rDateFind = ws2.Range(ws2.Cells(2, 1), ws2.Cells(1, LC2)).Find(What:=(rvall), LookIn:=xlFormulas, LookAt:=xlWhole)
            If Not rDateFind Is Nothing Then
            ws2.Cells(RValueFind.Row, rDateFind.Column).Value = ws1.Cells(rCell.Row, "W").Value
                
     End If
            Else
                strNotFound = strNotFound & ", " & rCell
            End If
    
    Next rvall
    
    MsgBox ("RACF match: " & strFound & vbCr & "RACF not found: ")
    
    
    End Sub
    Last edited by Eric111; 12-06-2014 at 10:51 PM. Reason: Updating post

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Help To Fix Part Of Macro That Does Not Filter Data Properly
    By chicalaeti in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-09-2014, 12:27 PM
  2. [SOLVED] IF data on opened worksheet has blank data then cancel macro and move onto next part
    By jonathan.haynes in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-01-2013, 07:11 AM
  3. [SOLVED] Excel Command Button Macro to ask for Part # and update another sheet with info
    By dka5034 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 02-14-2013, 08:36 AM
  4. Find Part number through Macro and output to associated part to certain cell
    By boylers75 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-09-2012, 04:32 PM
  5. macro that would erase part of data in a cell?
    By tradewindrider in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-17-2007, 02:09 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