+ Reply to Thread
Results 1 to 12 of 12

Copy Data Row By Row

Hybrid View

  1. #1
    Registered User
    Join Date
    01-27-2016
    Location
    Essex
    MS-Off Ver
    2013 Pro
    Posts
    43

    Copy Data Row By Row

    Hi All

    I have a spreadsheet which has 32 branch locations in the consolidation sheet and this works fine and consolidates all the data from 2 other sheets, My problem is that I now need a macro which can copy out row by row to each of the branch destination sheets but not remove the data from the consolidation sheet (if that makes any sense?)

    So lets say the first branch is called Barking then what I need the macro to do is look at the consolidation sheet identify the coloumn & row with Barking branch in it(Branch Name is always in coloumn "B" and then copy data from Col "C" to Col "I" in what ever row Barking sits?and then continue doing this until all location data has been copied to relevant branch sheet!

    All these sheets are in a Workbook called "Data Entry"

    Is this possible I ask?

    Await anyones help on this

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,913

    Re: Copy Data Row By Row

    Create a unique list of all branches and loop through that list to set autofilter criteria. Then copy filtered rows to branch sheet and move on to next item in unique branch list.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Registered User
    Join Date
    01-27-2016
    Location
    Essex
    MS-Off Ver
    2013 Pro
    Posts
    43

    Re: Copy Data Row By Row

    Hi

    Not sure how that would be done?I have upload a copy of the sheet perhaps you can figure out why the macro on the data sheet will not copy into the relevant sheets named branches?

    Hope you can sort it?

  4. #4
    Valued Forum Contributor Kamboj's Avatar
    Join Date
    09-25-2014
    Location
    India
    MS-Off Ver
    2003 - 2010
    Posts
    430

    Re: Copy Data Row By Row

    First create all sheets with branch name. Here I created 3 sheets - a,b & c.
    Attached Files Attached Files
    Kamboj
    _________________________________________________________________________________
    Mark the thread as SOLVED if my answer satisfy you.

  5. #5
    Registered User
    Join Date
    01-27-2016
    Location
    Essex
    MS-Off Ver
    2013 Pro
    Posts
    43

    Re: Copy Data Row By Row

    Hi

    Thanks for that but when I look at the macro couldn't get my head round what it was doing?

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,913

    Re: Copy Data Row By Row

    Sub TransferWeeklyData()
    
    
    Rem If MsgBox("Do You Want To Now Clear The Current Data Entered To Its Relevant Destination Sheets?If You Choose Yes then this will Clear And Transfer Your Data If You Choose No Then This Will Return To The Data Entry Sheet With No Action Taken?", vbQuestion + vbYesNo) = vbNo Then Exit Sub
    Rem If MsgBox("Have You Checked That You Have Entered Correct Week Number?", vbQuestion + vbYesNo) = vbNo Then Exit Sub
    
    Dim ws As Worksheet, wsDATA As Worksheet
    Dim LR As Long, Rw As Long, wkRw As Long, Wk As Long
    
    Set wsDATA = Sheets("Data Entry")
    Wk = wsDATA.Range("L2").Value
    LR = wsDATA.Range("A" & Rows.Count).End(xlUp).Row
    
    For Rw = 2 To LR
        If WorksheetFunction.CountA(wsDATA.Range("C" & Rw).Resize(, 7)) > 0 Then
            With Sheets(wsDATA.Range("B" & Rw).Value & " " & wsDATA.Range("A" & Rw))
                .Cells(Application.Match(Wk, .Columns(1), 0), 2).Resize(, 7).Value = wsDATA.Range("C" & Rw).Resize(, 7).Value
            End With
        End If
    Next Rw
    
    End Sub

  7. #7
    Registered User
    Join Date
    01-27-2016
    Location
    Essex
    MS-Off Ver
    2013 Pro
    Posts
    43

    Re: Copy Data Row By Row

    Thank you bakerman2 works well will just add clearcontents to end of macro now and that should clear the data entry sheet?

    thks once again

  8. #8
    Registered User
    Join Date
    01-27-2016
    Location
    Essex
    MS-Off Ver
    2013 Pro
    Posts
    43

    Re: Copy Data Row By Row

    Hi

    Sorry to bother you again but its stopped working on the following line?

    .Cells(Application.Match(Wk, .Columns(1), 0), 2).Resize(, 7).Value = wsDATA.Range("C" & Rw).Resize(, 7).Value

    Have no idea why as all I have done is entered data in the data entry sheet ready to send to all the other sheets?

    Any ideas?

  9. #9
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,913

    Re: Copy Data Row By Row

    wsDATA.Range("C2:I" & LR).ClearContents
    Thanks for the rep.

  10. #10
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,913

    Re: Copy Data Row By Row

    No Weeknumber in L2 ? Invalid weeknumber ? Weeknumber missing in one of the sheets ?
    In your example file it works perfectly.

  11. #11
    Registered User
    Join Date
    01-27-2016
    Location
    Essex
    MS-Off Ver
    2013 Pro
    Posts
    43

    Re: Copy Data Row By Row

    Hi

    Yep! what an idiot I am..lol I forgot to place a week number in there so it stopped working..lol

    Thank you again for all the help and really sorry to bother you will look next time before asking..lol

  12. #12
    Registered User
    Join Date
    01-27-2016
    Location
    Essex
    MS-Off Ver
    2013 Pro
    Posts
    43

    Re: Copy Data Row By Row

    sorted it was a wrong name?
    Last edited by Gatewaya89; 06-18-2016 at 09:26 AM.

+ 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. Copy data from sheet1 column with dynamic date, and copy data to second sheet column
    By Renaliiii in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-25-2016, 04:44 PM
  2. Copy & paste input data to sheet, copy result back out
    By stuartsjg in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-30-2015, 05:25 PM
  3. Saving copy of data and then running macro on all active worksheets in saved copy?
    By Science87 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-09-2014, 11:56 AM
  4. [SOLVED] Copy data with 4 cell interval and copy range of data like vlookup with structured output
    By Daydreams in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-23-2013, 04:08 AM
  5. Replies: 4
    Last Post: 05-20-2013, 11:37 AM
  6. Enter data, copy formulas, copy values, paste data, delete data
    By alf40 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-15-2013, 07:23 PM
  7. Macro to copy Dyanmic lists then copy sheet and clear the original data
    By twiggywales in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-30-2012, 01:06 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