Transfer an entire row from one sheet to another [Solved/Closed]

Report
-
Posts
1292
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
May 7, 2021
-
Good Evening,

I seriously need major help. Please!! Please!! Please!!

I have an inventory of over 600+ items (rows) each row has 12 columns with descriptions of the product-the last column is name buyer(where I put who purchase the item, If know one has bought the item then is blank. I want to be able to transfer all the blank ones to a separate sheet without having to copy and paste. I don't know much about excel but I guess it would be an equation or macro that would transfer the entire row if the buyer column is blank.

Thank you so much


5 replies

Posts
1292
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
May 7, 2021
229
Hello JC,

See if the following code will do the trick for you:-


Sub TransferStuff()

Application.ScreenUpdating = False
Application.DisplayAlerts = False


     Range("L1", Range("L" & Rows.Count).End(xlUp)).AutoFilter 1, ""
     Range("A2", Range("K" & Rows.Count).End(xlUp)).Copy Sheet2.Range("A" & Rows.Count).End(3)(2)
     Range("A2", Range("K" & Rows.Count).End(xlUp)).Delete
     [L1].AutoFilter
    
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Sheet2.Select

End Sub


The code will filter on Column L for blank cells and will transfer the relevant row of data to sheet2. The code will also delete the "used' data from sheet1.

Following is the link to my test work book for you to peruse:-

https://www.dropbox.com/s/hvptuv6w5ehlaox/JC%28Transfer%20rows%20with%20empty%20cells%20in%20Column%20L%29.xlsm?dl=0

Click on the button to see the code at work

I hope that this helps.

Cheerio,
vcoolio.
Thank you so much, this really really makes my life easier.
One last question and sorry to bother you- instead of deleting the row could I just hide it?
I looked it up and I only saw an option to hide the whole sheet with "visible=false"

Once again thank you so much
Posts
1292
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
May 7, 2021
229
Hello JC,

Remove line 10 from the code above then place the following line of code:-

Columns("L").SpecialCells(4).EntireRow.Hidden = True


just under this line of code:-

[L1].AutoFilter


That should do the trick for you.

Cheerio,
vcoolio.
Thank you so much for helping me out. This really helps with my inventory!
Posts
1292
Registration date
Thursday July 24, 2014
Status
Moderator
Last seen
May 7, 2021
229
Hello JC,

You're welcome. I'm glad that I was able to help.

Cheerio,
vcoolio.

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!