+ Reply to Thread
Results 1 to 3 of 3

Copying a row to new sheet based on a cell value

  1. #1
    Registered User
    Join Date
    07-21-2015
    Location
    new york
    MS-Off Ver
    MS excel 2010
    Posts
    4

    Unhappy Copying a row to new sheet based on a cell value

    For sample, the code below copies all the rows in the "Materlist" sheet that contains "Brooklyn" on column E to the sheet named "Brooklyn" in the same workbook. I have a sheet named for each value on column E of the Masterlist, about 35, and would like to separate the data to it's own sheet when new data is enter in the master list. The masterlist gets updated by several people, but I have to separate the data to it's own sheet, so I am trying to make the process more efficient. I already have a code to create a new sheet for every unique value in column E of the master list, now I want it to move that data to the sheet it created. The code below works but it is not automatic. How can I make it so it moves data(entire row) for all values on column E to the sheet named after that value.


    Sub Cheezy()
    Dim xRg As Range
    Dim xCell As Range
    Dim I As Long
    Dim J As Long
    I = Worksheets("Masterlist").UsedRange.Rows.Count
    J = Worksheets("Brooklyn").UsedRange.Rows.Count
    If J = 1 Then
    IF Application.WorksheetFunction.CountA(Worksheets("Brooklyn").UsedRange) = 0 Then J = 0
    End If
    Set xRg = Worksheets("Masterlist").Range("E1:E" & I) On Error Resume Next
    Application.ScreenUpdating = False
    For Each xCell In xRg If CStr(xCell.Value) = "Brooklyn" Then xCell.EntireRow.Copy Destination:=Worksheets("Brooklyn").Range("A" & J + 1) xCell.EntireRow.Delete J = J + 1
    End If
    Next Application.ScreenUpdating = True
    End Sub

  2. #2
    Forum Expert Doc.AElstein's Avatar
    Join Date
    05-23-2014
    Location
    '_- Germany >Outside Building things.... Mostly
    MS-Off Ver
    Office 2003 2007 2010 PC but Not mac. XP and Vista mostly, sometimes Win 7
    Posts
    3,618

    Re: Copying a row to new sheet based on a cell value

    Hi len2088,

    First, could you use Code Tags please:
    Instead of posting something like this:

    Sub Cheezy()
    '
    End Sub

    Use the # editor icon , to get BB Code Code tags, or add those Tag pairs manually like this:
    [CODE]Sub Cheezy()
    '
    End Sub[/CODE]

    That has the effect that when posted, the code comes out in a nice code window

    Have a go at Editing your Post #1 please to add those tags and then Save to repost. ( Note: there is a Forum Software Bug which sometime cause the original contents to vanish without trace when you hit the Edit button, so you might want to copy the post contents to the clipboard before you hit the Edit button, so that you can re-paste in the case that the original contents vanish unexpectedly. )
    _.______

    Second, When you get time, please read the forum rules – all the jem on stuff like code tags is there:
    http://www.excelforum.com/forum-rule...rum-rules.html
    http://www.excelforum.com/forums-rules/
    http://www.excelforum.com/developmen...ml#post4606484


    _.___________

    Finally, to your request for help:
    There are lots of ways to achieve what you want.
    It would be most helpful if you could give us some sample data, reduced in size, and you can make the data up if you like so as not to give sensitive data. But keep the data type representative of typical data types and formats and choose it carefully so that it covers all typical scenarios in the data.

    Here is some jem on getting data across to us:_.....
    https://www.excelforum.com/developme...ml#post4532042
    _.....The simplest thing to do would be to upload us two files, the Before, and After
    The Before is your reduced size sample data. The After is the modified Before, showing exactly what you want the code to do. In other words, you do manually in the After what you want the code to do.
    And say again exactly what action should cause that code to run.

    Alan
    '_- Google first, like this _ site:ExcelForum.com Gamut
    Use Code Tags: Highlight code; click on the # icon above,
    Post screenshots COPYABLE to a Spredsheet; NOT IMAGES PLEASE
    http://www.excelforum.com/the-water-...ml#post4109080
    https://app.box.com/s/gjpa8mk8ko4vkwcke3ig2w8z2wkfvrtv
    http://excelmatters.com/excel-forums/ ( Scrolll down to bottom )

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel (Windows 11 64-bit)
    Posts
    62,060

    Re: Copying a row to new sheet based on a cell value

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" to anyone who has offered you help in your thread. You can reward them by clicking on * Add Reputation below theur user name on the left, if you wish.


    Forum Rules (updated September 2018): please read them here.
    How to use the Power Query code you've been given: help here. More about the Power suite here.

+ 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. Copying a row to another sheet based on a cell value from a list
    By r.whilock in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-23-2015, 08:27 PM
  2. Copying a portion of a row based on cell criteria to another sheet
    By lucky.vjn in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-20-2015, 04:05 PM
  3. Copying a selected row to another sheet based on cell value
    By Ixorian in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-23-2014, 01:27 PM
  4. Copying data from one sheet to another based on cell color
    By Redcarn in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-20-2012, 03:16 AM
  5. Copying row based off cell value to a sheet of the same name
    By hambly in forum Excel Programming / VBA / Macros
    Replies: 52
    Last Post: 11-23-2011, 06:12 PM
  6. Replies: 4
    Last Post: 03-22-2011, 02:26 AM
  7. copying from one sheet to another based on cell value
    By tinkerbelle in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-30-2010, 06:51 AM

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

X vBulletin 4.1.8 Debug Information

  • Page Generation 0.06242 seconds
  • Memory Usage 8,964KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)footer
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (3)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (4)navbar_noticebit
  • (6)option
  • (3)postbit_legacy
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (4)showthread_bookmarksite
  • (7)showthread_similarthreadbit
  • (1)showthread_similarthreads
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper
  • (1)vbseo_linkbackmenu_entry 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (39):
  • ./vbseo.php
  • ./env.php
  • ./vbseo/includes/functions_vbseo.php
  • ./vbseo/includes/functions_vbseo_pre.php
  • ./vbseo/includes/functions_vbseo_url.php
  • ./vbseo/includes/functions_vbseo_createurl.php
  • ./vbseo/includes/functions_vbseo_db.php
  • ./vbseo/includes/functions_vbseo_vb.php
  • ./vbseo/includes/functions_vbseo_seo.php
  • ./vbseo/includes/functions_vbseo_misc.php
  • ./vbseo/includes/functions_vbseo_crr.php
  • ./vbseo/includes/functions_vbseo_cache.php
  • ./vbseo/includes/functions_vbseo_hook.php
  • ./vbseo/includes/functions_vbseo_startup.php
  • ./includes/config.php
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/functions.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/functions_cforum.php
  • ./includes/functions_facebook.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (49):
  • init_startup
  • friendlyurl_resolve_class
  • database_pre_fetch_array
  • database_post_fetch_array
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • fetch_musername
  • cache_templates
  • template_register_var
  • parse_templates
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • reputation_image
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit
  • tag_fetchbit_complete
  • showthread_similarthread_query
  • showthread_similarthreadbit
  • forumrules
  • showthread_bookmarkbit
  • navbits
  • navbits_complete
  • showthread_complete


Search Engine Friendly URLs by vBSEO 3.6.0 RC 1