+ Reply to Thread
Results 1 to 6 of 6

VBA Match Cell Range to Worksheet Name and copy/paste to respective worksheet

  1. #1
    Forum Contributor
    Join Date
    11-20-2011
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2007, Excel 2003, Excel 2010
    Posts
    284

    VBA Match Cell Range to Worksheet Name and copy/paste to respective worksheet

    Hello,

    I have a tab named "Data" and 2 other tabs named Bill and Jim. Column A in the Data tab contains Names of employees (Jim and Bill) and all employees have a corresponding tab. What I am trying to do is match the names in column A of the "data" tab with the corresponding sheets that have the same names and then paste the names into their respective sheets in column A. Everytime I populate I am trying to get it to paste in the next empty row. In the "data" tab there might be 5 entries for Jim and 3 for Bill and I am trying to get the 5 Jim entries to paste in the Jim tab and the 3 Bill entries to paste in the Bill tab. Any help on this would be greatly appreciated as I have been struggling with it for the past few hours.

    Thanks so much for your help in advance.
    The code below somewhat works but i cannot include the entire column.

    Public Sub sheettosheet()
    Dim wksht As Worksheet
    For Each wksht In Sheets
    If ActiveSheet.EntireColumn("A3").Value = wksht.Name Then
    ActiveSheet.Range("B3:U3").CurrentRegion.Copy Destination:=wksht.Range("A" & Rows.Count).End(xlUp).Offset(1)
    End If
    Next
    End Sub
    Last edited by rlsublime; 11-20-2011 at 07:00 PM. Reason: added details

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA Match Cell Range to Worksheet Name and copy/paste to respective worksheet

    It will be easier if you attach a sample workbook so we can provide you a solution easily.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: VBA Match Cell Range to Worksheet Name and copy/paste to respective worksheet

    Quote Originally Posted by rlsublime View Post
    Public Sub sheettosheet()
    Dim wksht As Worksheet
    For Each wksht In Sheets
    If ActiveSheet.EntireColumn("A3").Value = wksht.Name Then
    ActiveSheet.Range("B3:U3").CurrentRegion.Copy Destination:=wksht.Range("A" & Rows.Count).End(xlUp).Offset(1)
    End If
    Next
    End Sub
    There is no EntireColumn("A3")
    There is no value to an EntireColumn.
    CurrentRegion picks up ALL cells that are surrounded by empty cells. Assuming that you have data in rows 3 to 50, Range("B3:U3").CurrentRegion would pick up "A3:U52".
    Try this: (I did this on the fly without testing, so back up).

    Please Login or Register  to view this content.
    Foxguy

    Remember to mark your questions [Solved] and rate the answer(s)
    Forum Rules are Here

  4. #4
    Forum Contributor
    Join Date
    11-20-2011
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2007, Excel 2003, Excel 2010
    Posts
    284

    Re: VBA Match Cell Range to Worksheet Name and copy/paste to respective worksheet

    Thanks so much foxguy! This worked perfectly!

  5. #5
    Registered User
    Join Date
    08-18-2008
    Location
    Houston
    Posts
    17

    Re: VBA Match Cell Range to Worksheet Name and copy/paste to respective worksheet

    Hi,

    How would I modify/adapt this code to start pasting data from let's say from C25...I try number of things and it seems that I'm keep missing something...

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.
    Thanks a lot.
    Izet

  6. #6
    Registered User
    Join Date
    12-01-2012
    Location
    Texas
    MS-Off Ver
    Excel 2003, 2007
    Posts
    1

    Re: VBA Match Cell Range to Worksheet Name and copy/paste to respective worksheet

    This worked beautifully. Saved me at least 2 hours of manually cutting and pasting or building a macro from scratch.

+ 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