VBA to Move rows Automatically from one sheet to another

kclynn19

New Member
Joined
Oct 12, 2022
Messages
5
Office Version
  1. 2011
Platform
  1. Windows
I watched a video on you tube on how to do this but I don't know what I am doing wrong. I keep getting an error when I go to debug. The first error is on the second line. I am unsure how to upload a mini sheet.
The code used:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
a = Worksheets("Sheet1").Cells(Rows.Count, 1).End(xIUP).Row

For i = 2 To a
If Worksheets("Sheet1").Cells(i, 14).Value = "C" Then
Worksheets("Sheet1").Rows(i).Cut
Worksheets("Complete").Activate
b = Worksheets("Complete").Cells(Rows, Count, 1).End(xIUP).Row
Worksheets("Complete").Cells(b + 1, 1).Select
ActiveSheet.Paste
Worksheets("Sheet1").Activate
End If

Next
For i = 2 To a
If Worksheets("Sheet1").Cells(i, 1).Value = "" Then
Rows(i).Delete
End If
Next


End Sub
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi, you have a typo here at the end of the line :

Excel Formula:
.End(xlUp).Row

should be lowercase x, lowercase l (L) , uppercase U lowercase p as I have it above.
cheers
Rob
 
Upvote 0
Hi, you have a typo here at the end of the line :

Excel Formula:
.End(xlUp).Row

should be lowercase x, lowercase l (L) , uppercase U lowercase p as I have it above.
cheers
Rob
Hi, thank you but I am still receiving this error.
1665661636921.png

on this line
1665661683553.png
 
Upvote 0
Hi, I can't get it to fail on that line - it works ok for me, cuts and pastes accordingly.

Have you got this code stored in a "module" or is it stored in the "worksheet" (ie. "Sheet1" codespace) ? it should be on Sheet1.

There was also a typo on the 7th line, you have a comma rather than a fullstop in the (Rows,Count, 1) - should be (Rows.count,1)

Rgds
Rob

1665665319826.png
 
Upvote 0
Rob, I have very little experience with visual basic, so I apologize. I believe I have it stored in the worksheet codespace.
 
Upvote 0
I understand, no problem. The only other thing I can think of then is that your "Sheet1" worksheet name is not called "Sheet1" - maybe you called it "sheet1" or "Sheet1 " possibly ?
have a check on your tabname - its case sensitive and wont like spaces after it either.

Rob
 
Upvote 0
Solution
I understand, no problem. The only other thing I can think of then is that your "Sheet1" worksheet name is not called "Sheet1" - maybe you called it "sheet1" or "Sheet1 " possibly ?
have a check on your tabname - its case sensitive and wont like spaces after it either.

Rob
Ok, I will do that. I appreciate your help.
 
Upvote 0
Thank you. It is actually working now. I really appreciate your help!
 
Upvote 0

Forum statistics

Threads
1,215,387
Messages
6,124,633
Members
449,177
Latest member
Sousanna Aristiadou

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