+ Reply to Thread
Results 1 to 2 of 2

Copy information from one to other worksheet

Hybrid View

  1. #1
    Registered User
    Join Date
    08-17-2012
    Location
    Maribor
    MS-Off Ver
    Excel 2003
    Posts
    1

    Copy information from one to other worksheet

    Hi I am new in making macro.

    I don’t know how to do this (for the example):

    I have 30+ worksheets and in the last worksheet are data which I want to copy in all other worksheets.

    First I would like to select information in cell "C2" in first worksheet and then I would like to find this information in the last worksheet. When I would found this information in the last worksheet I would like to copy cell right from that information (for the example: If the information from c
    "C2" in the first worksheet is in the cell "B15" in the last worksheet I would like to copy information which is in the cell "C15") back to the first worksheet in cell C24 (for the example).

    So, I would like to repeat this process for all 30+ worksheets.

    Can someone help me please.

    I found soulution with function VLOOKUP.

    Thanks
    Last edited by timor; 08-17-2012 at 04:25 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Copy information from one to other worksheet

    Assuming all the values to check are in C2 of each sheet, the last sheet name is something specific like "Database", and found items copy back to cell C24 of each sheet, something like this would do it:

    Option Explicit
    
    Sub UpdateFromDatabase()
    Dim wsDB As Worksheet, ws As Worksheet
    Dim vFIND As Range
    
    Set wsDB = Sheets("Database")
    
    On Error Resume Next
    For Each ws In Worksheets
        If ws.Name <> wsDB.Name Then
            Set vFIND = wsDB.Range("B:B").Find(ws.Range("C2").Value, LookIn:=xlValues, LookAt:=xlWhole)   'xlPart for partial matches
            If Not vFIND Is Nothing Then
                ws.Range("C24").Value = wsDB.Range("C" & vFIND.Row).Value
                Set vFIND = Nothing
            End If
        End If
    Next ws
    
    End Sub
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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