• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Automatically copy a row of data to another worksheet based on criteria

RTowles

Member
I have an audit tool I created. As you can see in the image I am using checkboxes, but they have a target reference of TRUE & FALSE. If the checkbox is not checked then the reference is FALSE; if the checkbox is checked then the reference is TRUE. I am presuming I'll need VBA coding as when I googled that seemed to be the direction everyone was going in (even if they didn't share the code unless you subscribed to them :O), and the only youtube video I saw that came close was one that moved the whole row, but I don't want the row to be moved, but copied.

My problem: If a checkbox is checked (or marked as true) then copy the whole row to a different worksheet, titled workplan. If we have multiple checkboxes marked then I would need all of that data copied over. For example if we have 5 minor concerns than I would need all 5 rows to be copied over to the workplan to be planned and worked. I need this to be done automatically (as soon as a checkbox is marked) without me pushing a button to run, if possible.

*In the picture below I won't have the TRUE/FALSE statements, it will be blank (see Meet Standards); I added them only for reference.

audit pic ii.png
 

RTowles

This sample basically will do - as You've written.
This sample misses those checkboxes - but test to write TRUE - then You'll see it works.
or You can add needed checkboxes as with Your real file.
There is a sample code.
If Your sheets layout is same
then this should work with Your real file too - I used my default layout.
You can modify my code as You need.
 

Attachments

  • RTowels.xlsb
    17.1 KB · Views: 11
I clicked on the attached file and I went to your developer and then to the code and it is not working for me. is this the correct code below? if so, it didn't pull the data over.
 
Last edited by a moderator:

RTowles

As I wrote ... test to write TRUE
You can use it only from via sheet.
There is only one code and it worked with me.
It works as You wrote - copy 'TRUE' -row at once to workplan-sheet.
 
I'm sorry. I'm an intermediate Excel user. I understood everything, but you're last line. I apologize and I get I'm stupid, but could you break it down a little more for me. What does "It works as You wrote - copy 'TRUE' -row at once to workplan-sheet." mean? Please help me and again I apologize that I'm not comprehending.
 
It means almost same as If a checkbox is checked (or marked as true) then copy the whole row to a different worksheet, titled workplan
test this:
#1 select Workplan-sheet
#2 count number of rows which has data
#3 select Sheet1-sheet
#4 select cell H12
#5 write TRUE and press <ENTER>
#6 select Workplan-sheet
#7 there will be a new row with its data
#8 repeat steps from #2 if needed
 

RTowles

2nd sample
Select cell below Meets.., Minor... or Major... then 'checkbox' will change status.
( if same row Employee File has something )
 

Attachments

  • RTowels.xlsb
    17.7 KB · Views: 8
Your sample file does not work for me, so I cannot test it to be true. Even when I followed your instructions exactly nothing changed. Your code does not do anything when I play around with it which is why I asked for further clarification. I repeat your sample file does not do anything, it does not automatically parse information, it does not automatically copy any information, the code does not do anything; which is why I copied the code, pasted it, and needed your clarification we were looking at the right things. As again, it does not work for me.

I am really hopping this won't be too difficult, but is it too complicated to only copy the data? Maybe because Cells A, B, C, and D are merged and not all in one cell?

I tried pasting another picture (below) and maybe this would be easier to understand. Each section has information. Once a checkbox is marked I would like to copy that whole row to another sheet in the same workbook.

1729024162413.png
 

RTowles

I cannot make Your snapshots work.
You should able to send a sample Excel -file instead of snapshots.
My sample file do not have merged cells.
My sample file can have different layout than Yours (as I've written), that's why - Your copied my code cannot work.
There can be many kind of differences which all have to take care.
 
Please see the sample file. Not sure why your sample file not working for me has anything to do with my file, but please take a look at the sample file.
 

Attachments

  • TESTING.xlsm
    71.1 KB · Views: 5

RTowles

There were some details okay and many ... something else ... too many.
I did some minor changes and it works here.
~after select 'Minor' or 'Major' -cells
~ if selected cell shows like [ x ] then three cells values will copy to other sheet
Note that there are none 'checkboxes' anymore - more userfriendly to take care these.
Those Your Merged Notes and Recommendations values will copy too (if You'll unmerge those cells then ... You'll have a challenge).
I added [ Reset [ ] ] -button (right top) to 'reset' all 'checkboxes' to [ ].
 

Attachments

  • TESTING.xlsb
    27.2 KB · Views: 7
I'm presuming this is not possible the way I have my file set up and their is no code that can just copy over the row based off the text True.
 

RTowles

One long sentence ...
If Your own file has SAME layout ...
... then copy and paste above files whole sheet over Your own.
Copy and paste my code in Your own file IN SAME PLACE.
... that [ Reset ]-button is possible to copy, BUT...

Or
move that sheet from my file to Your file.

The most smoother way is to use my above file.
 
Let's try something different. I would like to get help on a code that I was able to find that I think should help that does not change the formatting of my created excel sheet.

Can someone please advise why the code is not working when I click Run Macros.

Sheet1.Range - I turned this to F3 to test it out. I tried using F:F, but I'm not sure if this code includes blank in the data
Sheet2.Range - A2 is blank and the copied information should have populated to Sheet2 A2 location
if Status = TRUE then copy the entire row and pastecell, why is this not working?
Sub CopyOverBudgetRecords()

Dim StatusCol As Range
Dim Status As Range
Dim PasteCell As Range
Set StatusCol = Sheet1.Range("F3")

For Each Status In StatusCol

If Sheet2.Range("A2") = "" Then
Set PasteCell = Sheet2.Range("A2")
Else
Set PasteCell = Sheet2.Range("A1").End(xlDown).Offset(1, 0)
End If
'If Status = "TRUE" Then Status.EntireRow.Copy PasteCell
Next Status

End Sub
 

Attachments

  • Mock Audit Test.xlsm
    39.4 KB · Views: 2

RTowles

You skipped to comment - how Your original thread works?

You wrote - Let's try something different.

As You've read from Forum rules:
Start a new post every time you ask a question, even if the theme is similar.
 
You're absolutely right. I started to create a new thread and then second guessed myself out of it. I'll start a new one and request this one closed. Good point.
 
Back
Top