Macro Help

amwalo

New Member
Joined
Jun 9, 2022
Messages
8
Office Version
  1. 365
Platform
  1. Windows
I am trying to make my code work on the entire column by clicking a button. I am trying to get it to work with out having to highlight and having the one click take car of the entire column if that makes sense. The code deletes an entire row with completed in the column and moves it to another sheet. Side question is there a way to have it work by just hitting enter after entering completed?

Here is my code:

'VBA Code by Scott from SpreadsheetPlanet.com
Sub move_rows_to_another_sheet()
For Each mycell In Selection.Columns(9).Cells
If mycell.Value = "Completed" Then
mycell.EntireRow.Copy Worksheets("Completed").Range("A" & Rows.Count).End(3)(2)
mycell.EntireRow.Delete
End If

Next

End Sub
 
I tried the macro on some dummy data and it worked properly. It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach a screenshot (not a picture) of your sheet. Alternately, you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).
 
Upvote 0

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
I was able to reproduce your type-mismatch error. It occurred when more than once cell in column I was changed at the same time. Do you have any formulas in Column I that would change when anyone types "Completed"?
 
Upvote 0
I was able to reproduce your type-mismatch error. It occurred when more than once cell in column I was changed at the same time. Do you have any formulas in Column I that would change when anyone types "Completed"?
I have conditional formatting to turn it green.
 
Upvote 0
That should not be an issue... Try this:
change:
If target.Value = "Completed" Then

to

If target.text = "Completed" Then
 
Upvote 0

Forum statistics

Threads
1,215,327
Messages
6,124,287
Members
449,149
Latest member
mwdbActuary

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top