Results 1 to 5 of 5

(Excel VBA) Copy and Paste from one worksheet to multiple worksheets by names

Threaded View

  1. #1
    Registered User
    Join Date
    01-30-2015
    Location
    Austin, TX
    MS-Off Ver
    2010
    Posts
    2

    Question (Excel VBA) Copy and Paste from one worksheet to multiple worksheets by names

    Hello Everybody. First time post but long time follower of Excel and VBA posts on here. I have searched this site to help me solve this specific problem but so far I am only able to come up with the code to make this work for one condition at a time (can't replicate it for a loop).

    So here is my dilemma...

    I have a worksheet with a tab called "All Data" that has a column with information that matches the names of the other worksheets (tabs). What I want to be able to do is run a script that will look for and execute the following:
    • VB script will look at the worksheet “All Data” and where it finds
      “Column B – Reporting = No”
      It will copy and paste into a tab (worksheet) that matches the name of what is in “Column C”
      Do this for all districts listed in Column C. Amarillo to Paris
      Ex: Found Reporting=No for Amarillo. Copy and paste all “Reporting = No” data for Amarillo into the Amarillo worksheet (tab)
      Ex: Then found Reporting=No for Austin. Copy and paste all “Reporting=No” data for Austin into the Austin worksheet (tab)
      So on and so on until it hits Paris and then it will stop after that

    I will attach the spreadsheet but here is the code I came up with so far but it only works for one occurrence of a district's name at a time. I can't seem to figure out the coding to make it do it for all occurrences, match them up and copy/paste to their respective district's tab.

    I know that a pivot table would be the easiest but for what I am trying to do, this actually makes more sense and is easier to distribute to our people.

    I want to thank you all in advance for your help with this!

    Private Sub Workbook_Open()
    Dim i, LastRow

    LastRow = Sheets("All Data").Range("A" & Rows.Count).End(xlUp).Row
    Sheets("Amarillo").Range("A1:I500").ClearContents
    For i = 1 To LastRow
    If Sheets("All Data").Cells(i, "B").Value = "No" And Sheets("All Data").Cells(i, "C").Value = "Amarillo" Then
    Sheets("All Data").Cells(i, "C").EntireRow.Copy Destination:=Sheets("Amarillo").Range("A" & Rows.Count).End(xlUp).Offset(1)
    End If
    Next i
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy ranges from multiple worksheets in excel and then paste special in Powerpoint
    By mclarke2030 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-25-2013, 04:47 PM
  2. [SOLVED] Copy multiple worksheets data & paste into blank columns in summary worksheet
    By guest99999 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-21-2013, 09:56 AM
  3. [SOLVED] Search multiple worksheets for Text String, copy and paste entire row into new worksheet
    By spulliam2000 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-15-2013, 07:52 PM
  4. Copy data from multiple worksheets & paste into one worksheet.
    By Rodders in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 02-10-2012, 11:54 AM
  5. Replies: 1
    Last Post: 10-17-2005, 04:05 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