+ Reply to Thread
Results 1 to 7 of 7

If checkbox checked, cut row and paste on next sheet

  1. #1
    Registered User
    Join Date
    03-03-2013
    Location
    Florence, AL
    MS-Off Ver
    Excel 2007
    Posts
    7

    If checkbox checked, cut row and paste on next sheet

    I have a workbook with a report on Sheet1. If the checkbox in column N is checked, I need the data from that row (column A-S) to be cut and pasted on the next available row on Sheet2. I am still new to VBA/macros. Would this be better if I made a button to update the sheet every morning or could it be automatic when the checkbox is checked (preferred).

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: If checkbox checked, cut row and paste on next sheet

    Odds are you are using a "Form Control" checkbox rather than an "Active X" checkbox. This will work for an Active X checkbox. This is for row 1. Each row will need this copied into each checkbox and edited for the range

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    03-03-2013
    Location
    Florence, AL
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: If checkbox checked, cut row and paste on next sheet

    I have 500 rows. Are you saying I have to do this 500 times? If so, I wonder if there would be a more efficient way of doing this? Thank you for offering a solution though!

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: If checkbox checked, cut row and paste on next sheet

    How is your check box assigned to each row? Just by putting it in column N and a specific row doesn't automatically assign it to that row. (ie you should be able to also enter in a value in column N despite the checkbox being there). In other words, at the moment there is no way that your check boxes actually know which rows to manipulate so you have to create a way for each check box to recognize the row.

    There are many other ways of doing this (ie possibly linkedcells, or looping through each checkbox assuming they are in order) but unfortunately you have pigeon holed yourself a little here.

    More than likey what it sounds like you are going to need to do is use linked cells to trigger a True/False value in a corresponding N column. Then combine that with a Worksheet Change event specified to column N where if the value is true it copies the row over.

    Either way.....you are going to have to put some effort into this.
    Last edited by stnkynts; 03-06-2013 at 08:14 PM.

  5. #5
    Registered User
    Join Date
    03-03-2013
    Location
    Florence, AL
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: If checkbox checked, cut row and paste on next sheet

    Here's the VBA I ran to place my boxes and make my assignments

    Sub AddCheckBoxes()

    Dim cb As CheckBox
    Dim myRange As Range, cel As Range
    Dim wks As Worksheet

    Set wks = Sheets("Sheet1") 'adjust sheet to your needs

    Set myRange = wks.Range("A1:A10") ' adjust range to your needs

    For Each cel In myRange

    Set cb = wks.CheckBoxes.Add(cel.Left, cel.Top, 30, 6) 'you can adjust left, top, height, width to your needs


    With cb

    .Caption = ""
    .LinkedCell = cel.Address

    End With

    Next

    End Sub

  6. #6
    Registered User
    Join Date
    07-10-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    1

    Re: If checkbox checked, cut row and paste on next sheet

    This code makes sense and does what I'm looking for except automatically set the checkbox to "False". I can't make sense of any other VBA code I've found to know how to enter such a simple thing into this VBA code. Can anyone provide that to me? Thanks so much!

  7. #7
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: If checkbox checked, cut row and paste on next sheet

    Please don't resurrect old posts. If you have a problem you need a solution to please start a new thread with your question. If this thread is relevant to your problem you can link this thread within your new post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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