Issues When Using VBA to Automatically Move Row to Another Sheet Based On Cell Value

EBe

New Member
Joined
May 23, 2023
Messages
13
Platform
  1. Windows
Hi,

I’m completely new to VBA and have previously used this site to find a code to automatically move a row to another sheet in excel based on cell value. It was all working fine until I upgraded my computer and transferred my files over, and for some reason it seems to have stopped working. I've tried to work it out but am completely lost!

I've opened VBA and inserted a new module using the code below but nothing seems to happen. I've tried to run the module, but no module appears when I click 'run'. The code is exactly the same as I was using before so I'm assuming it's user error somewhere. If anyone can point me in the right direction I'd be really grateful.

For reference, I'm trying to move a row of data from sheet 'active' to a new sheet 'processed' when the value in column J reads 'discharged'.

The code I’m using is:

Private Sub Worksheet_Change(ByVal Target As Range)

' Check to see only one cell updated
If Target.CountLarge > 1 Then Exit Sub

' Check to see if entry is made in column J after row 3 and is set to "Discharged"
If Target.Column = 10 And Target.Row > 3 And Target.Value = "Discharged" Then
Application.EnableEvents = False
' Copy columns A to J to Processed sheet in next available row
Range(Cells(Target.Row, "A"), Cells(Target.Row, "J")).Copy Sheets("Complete").Cells(Rows.Count, "J").End(xlUp).Offset(1, 0)
' Delete current row after copied
Rows(Target.Row).Delete
Application.EnableEvents = True
End If

End Sub
 
Thanks so much everyone for all your help. It’s pretty much running as it should now, hooray!

How do I get the message box which tells me ‘code is running’ to stop popping up every time I change something on the workbook?
Just delete that line that starts with "MsgBox" from your VBA code.

Glad to hear you got it all working now, and you hopefully learned some new VBA debugging techniques!
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Just delete that line that starts with "MsgBox" from your VBA code.

Glad to hear you got it all working now, and you hopefully learned some new VBA debugging techniques!
Thank you so much. Really appreciate all the help, I’m learning slowly!
 
Upvote 0

Forum statistics

Threads
1,223,162
Messages
6,170,431
Members
452,326
Latest member
johnshaji

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