+ Reply to Thread
Results 1 to 6 of 6

Copying several worksheets data to a master worksheet

Hybrid View

  1. #1
    Registered User
    Join Date
    07-03-2008
    Location
    Christchurch NZ
    Posts
    3

    Copying several worksheets data to a master worksheet

    I'm a newby to macros and would appreciate any help to achieve the following
    I may be going about this completly the wrong way, but here is what I want to achieve.
    I've got several worksheets that are used for storing different suppliers products and prices.
    These worksheets are used to input any new products & price changes from suppliers, usually done by copying and pasting the entire data in the
    appropriate worksheet with the new list from the supplier.
    Worksheets are named ACM ACA Avon Crawford Graphis Larson Visual
    Only 2 columns A & B are being used, A being "Product" & B "Price".
    Another worksheet is called "Master"
    that has the combined data from all the other worksheets.
    I use "Master" to search & maintain quantities and total stock prices etc.
    I would like a macro that would copy only new Product entries or changed prices from all my Suppliers worksheets to my Master worksheet,
    so it has to check to see if my "Master" worksheet already has the product entry first
    if not then add this new row at this position
    if exists already then check if the price has changed
    if changed then replace price

    Again any thoughts appreciated
    Last edited by hairy; 07-04-2008 at 03:07 AM. Reason: Undescriptive title

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Try this

    Sub ccc()
      Dim OutSH As Worksheet
      Set OutSH = Sheets("Master")
      
      For i = 1 To Sheets.Count
        If Sheets(i).name <> "Master" Then
          With Sheets(i)
            For Each ce In .Range("A2:A" & .Cells(Rows.Count, 1).End(xlUp).Row)
              If WorksheetFunction.CountIf(OutSH.Range("A:A"), ce.Value) = 0 Then
                OutSH.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Resize(1, 2).Value = ce.Resize(1, 2).Value
              Else
                Set findit = OutSH.Range("A:A").Find(what:=ce.Value)
                findit.Offset(0, 1).Value = ce.Offset(0, 1).Value
              End If
            Next ce
          End With
        End If
      Next i
            
    End Sub
    rylo

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    hairy

    Please take the time to read the Forum rules & use appropriate wording in your questions' Titles.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    07-03-2008
    Location
    Christchurch NZ
    Posts
    3

    Thanks a lot rylo

    I will have a play with it

  5. #5
    Registered User
    Join Date
    07-03-2008
    Location
    Christchurch NZ
    Posts
    3

    Works great rylo

    Another couple of thoughts if possible to be done easily

    As the worksheets the data is coming from all have different backgroud fill colours can that also be copied into Master

    If I have a new product added into a input worksheet, rather than always going to the bottom of the Master could it be positioned in the Master relative to which input worksheet it came from.

    Thanks hairy

  6. #6
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hairy

    1) Should be able to - do a copy / paste rather than transfer the values.
    2) How would you expect it to know where it would sit in the master list? Is there something else in the data that would show where it came from?

    Perhaps put up an example file so better show your details and how you would like it to appear.

    rylo

+ 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