+ Reply to Thread
Results 1 to 6 of 6

Want to copy data from one sheet to a specific row on another sheet when the adjacent cell

  1. #1
    Registered User
    Join Date
    04-25-2019
    Location
    Nottingham
    MS-Off Ver
    2007
    Posts
    3

    Want to copy data from one sheet to a specific row on another sheet when the adjacent cell

    example.jpg

    I have a workbook with four sheets showing sales against various departments in a few stores. The first sheet has a list of all departments in all stores in Column A

    The 2nd to 4th sheets contain the only the departments that had actual sales in column "A", and the Value of the Sales in Column "B". I am looking to run a macro to achieve the following:

    Check text in Column "A" in "Sheet2" and compare with Column "A" in "Sheet1", If a match is found copy the Value in Column "B" of "Sheet2" to the Cell adjacent to the matching Column "A" in Sheet 1

    Check text in Column "A" in "Sheet3" and compare with column A in Sheet 1, If a match is found copy the Value in Column "C" of "Sheet3" to the Cell adjacent to the matching Column "A" in "Sheet1"

    Check text in Column "A" in "Sheet4" and compare with column A in "Sheet1", If a match is found copy the Value in Column "D" of "Sheet4" to the Cell adjacent to the matching Column "A" in Sheet 1

    I have started with the below but seem to be failing badly....

    Thanks for any help.

    Sub MatchEntries()

    Dim WsA As Worksheet 'Sheet1
    Dim WsB As Worksheet 'Sheet2
    'Dim WsC As Worksheet 'Sheet3
    'Dim WSD As Worksheet 'Sheet4
    Dim Cell As Range ' Cells in RngA
    Dim Fnd As Range ' Find match
    Dim R As Long, C As Long ' row and column

    With ActiveWorkbook
    Set WsA = .Worksheets("Sheet1")
    Set WsB = .Worksheets("sheet2")
    ' Set WsC = .Worksheets("Sheet3")
    ' Set WSD = .Worksheets("sheet4")
    End With

    For Each Cell In WsB.Range("A1:A40")
    Set Fnd = WsA.Columns(1).Find(What:=Cell.Value, LookIn:=xlFormulas, LookAt:=xlWhole)

    If Fnd Is Nothing Then
    MsgBox "I couldn't find " & Cell.Value & " in worksheet 'Checklist'"

    Else
    R = Fnd.Row
    For C = 2 to 2

    WsA.Cells(R, C).Value = WsB.Cells(R, C).Value


    Next C

    End If

    Next Cell
    End Sub
    Attached Files Attached Files
    Last edited by Andrew_77; 04-25-2019 at 10:06 AM.

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Want to copy data from one sheet to a specific row on another sheet when the adjacent

    It's difficult to work with pictures. Could you attach a copy of your file?
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    04-25-2019
    Location
    Nottingham
    MS-Off Ver
    2007
    Posts
    3

    Re: Want to copy data from one sheet to a specific row on another sheet when the adjacent

    Thanks for the response.. File now attached (I think..)

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Want to copy data from one sheet to a specific row on another sheet when the adjacent

    Try:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-25-2019
    Location
    Nottingham
    MS-Off Ver
    2007
    Posts
    3

    Re: Want to copy data from one sheet to a specific row on another sheet when the adjacent

    Worked Perfectly Thanks very much for your help!!

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Want to copy data from one sheet to a specific row on another sheet when the adjacent

    My pleasure.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 16
    Last Post: 08-09-2017, 12:50 PM
  2. Replies: 0
    Last Post: 09-16-2015, 01:18 PM
  3. Auto copy specific data from sheet to antoher sheet under few condition
    By Shermaine2010 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-17-2014, 04:47 AM
  4. [SOLVED] Copy and paste data from sheet 2 to sheet 1 based on specific criteria on sheet 1
    By VBADUD in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-05-2012, 04:18 AM
  5. [SOLVED] Seach for data from one sheet to another sheet and copy past adjacent columns
    By mahtabshaikh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-19-2012, 10:19 AM
  6. Find Adjacent Data In One Sheet and Copy/Paste Into Other Sheet
    By jaylotheman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-06-2011, 07:19 PM
  7. If match between two sheets, copy adjacent cell from sheet 2 to sheet 1?
    By VBnoob in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-23-2011, 04:02 AM

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