+ Reply to Thread
Results 1 to 9 of 9

If certain value in cell then copy full row to another sheet

  1. #1
    Registered User
    Join Date
    08-24-2022
    Location
    hugo
    MS-Off Ver
    13
    Posts
    40

    Post If certain value in cell then copy full row to another sheet

    Hello,
    I am trying to figure out a VBA code that will copy a row to another sheet if the value in A is = to a certain number. I am trying to automate this as the real sheet has over 100 rows and manually moving them takes a very long time.

    I created a mocked up sample, see attached.

    Looking at the mocked up file, Sheet "Main" -
    If any cells in column A is = to 1234 and 1235, I would need a new sheet created called "Group1" and the Row/s would need to be copied into that sheet along with the headers
    If any cells are = to 1589, I would need a new sheet created called "Group2" and the row/s would have to be copied over into that sheet. along with the headers


    Any help would be greatly appreciated.
    Attached Files Attached Files
    Last edited by excelgirl84; 08-24-2022 at 04:31 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    05-03-2022
    Location
    Halifax,Canada
    MS-Off Ver
    365
    Posts
    326

    Re: If certain value in cell then copy full row to another sheet

    Please Login or Register  to view this content.
    ASSUMPTIONS:
    Source sheet is activesheet
    sample sheet provided is accurate in columns used
    target numbers are constant numbers located in column A of activesheet

    if this code has helped you please consider clicking "add reputation" , thx
    Last edited by nimrod1313; 08-24-2022 at 05:08 PM.

  3. #3
    Valued Forum Contributor rollis13's Avatar
    Join Date
    01-26-2012
    Location
    Cordenons
    MS-Off Ver
    Excel 2016 32bit - Win 11
    Posts
    935

    Re: If certain value in cell then copy full row to another sheet

    Hi to all.
    Oh well, I'm late. Anyway, here is what I came up with:
    Please Login or Register  to view this content.
    Last edited by rollis13; 08-24-2022 at 05:39 PM.

  4. #4
    Registered User
    Join Date
    08-24-2022
    Location
    hugo
    MS-Off Ver
    13
    Posts
    40

    Re: If certain value in cell then copy full row to another sheet

    Sorry, I think I made the mistake of putting the other sheets in there to start with. Technically, I would like the other sheets "group1" and "group2" to be created with the code along with the header row from the "Main" Sheet too. Not sure why I put them in there. Sorry about that! Super new to all this
    is there a way to edit your code to have the sheets created?

  5. #5
    Valued Forum Contributor
    Join Date
    05-03-2022
    Location
    Halifax,Canada
    MS-Off Ver
    365
    Posts
    326

    Re: If certain value in cell then copy full row to another sheet

    VERSION 2 .. creates sheets if do not exist

    Please Login or Register  to view this content.
    if this code has helped you please consider clicking "add reputation" , thx

  6. #6
    Registered User
    Join Date
    08-24-2022
    Location
    hugo
    MS-Off Ver
    13
    Posts
    40

    Re: If certain value in cell then copy full row to another sheet

    Wow! Works fantastic!! Thank you so much. I really appreciate all the fast help with this.

  7. #7
    Valued Forum Contributor
    Join Date
    05-03-2022
    Location
    Halifax,Canada
    MS-Off Ver
    365
    Posts
    326

    Re: If certain value in cell then copy full row to another sheet

    Hello ExcelGirl84
    Just curious, who's solution did you end up going with ?

  8. #8
    Registered User
    Join Date
    08-24-2022
    Location
    hugo
    MS-Off Ver
    13
    Posts
    40

    Re: If certain value in cell then copy full row to another sheet

    I'm guessing if i need to add more "numbers" and groups
    I would just do this?

    For Each num In Columns("A:A").SpecialCells(xlCellTypeConstants, 1)
    If num.Value = 1234 Or num.Value = 1235 Then
    addToArray Group1, Columns("A:M"), num.Row
    End If
    If num.Value = 1589 Then
    addToArray group2, Columns("A:M"), num.Row
    End If
    If num.Value = 1111 Then
    addToArray group3, Columns("A:M"), num.Row
    End If
    If num.Value = 2222 Then
    addToArray group4, Columns("A:M"), num.Row
    End If


    and so on?

  9. #9
    Registered User
    Join Date
    08-24-2022
    Location
    hugo
    MS-Off Ver
    13
    Posts
    40
    Quote Originally Posted by nimrod1313 View Post
    Hello ExcelGirl84
    Just curious, who's solution did you end up going with ?
    Your v2! I did the reputation thing for ya to!😀

+ 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. [SOLVED] copy full row to another sheet if conditions are satisfied
    By kv.singh in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-12-2021, 08:52 AM
  2. Copy text to cell, but if targeted cell is full, copy to next one
    By Marpik in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-06-2020, 12:02 PM
  3. Find and Copy ONLY Last full Row to Different Workbook Sheet
    By Techno16 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-11-2019, 05:41 PM
  4. Replies: 20
    Last Post: 06-26-2015, 02:52 PM
  5. [SOLVED] If cell is full, copy row to another sheet and workbook
    By pucval in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 09-21-2012, 08:14 AM
  6. How to copy sheet without full filename in named ranges?
    By jimojimo in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-23-2010, 10:52 AM
  7. Replies: 3
    Last Post: 08-18-2006, 07:55 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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1