Macro for moving rows

B

bojan0810

Hi all!

If someone can help me with this.

I have file, you have link there for download. It has macros in it ofc.

Macros are doing this.

From one sheet rows are moving to another. And opposite.

If I choose from drop down list (Redail) it should move to Redail sheet, and when I on Redail sheet if I choose Waiting on drop down list it should move to Waiting sheet. And same as for others sheets. "Sheets 6" and "Sheets 7" arent important for now.

Thing is, I used , if then else in code, and it comes to an error every time I try to move. Can someone help me with this.

If someone can help me to avoid that error. I am not sure what I am doing wrong.

Thanks

https://dl.dropboxusercontent.com/u/57916703/WorkExample030211.xlsm
 
C

Claus Busch

Hi,

Am Wed, 9 Apr 2014 03:04:54 -0700 (PDT) schrieb (e-mail address removed):
If I choose from drop down list (Redail) it should move to Redail sheet, and when I on Redail sheet if I choose Waiting on drop down list it should move to Waiting sheet. And same as for others sheets. "Sheets 6" and "Sheets 7" arent important for now.

Thing is, I used , if then else in code, and it comes to an error every time I try to move. Can someone help me with this.

delete all code in the code modules of the worksheets.
Paste following code into the code module of "ThisWorkbook":

Private Sub Workbook_SheetChange(ByVal Sh As Object, _
ByVal Target As Range)
If Sh.Name = "Sheet7" Then Exit Sub

If Intersect(Target, Sh.Range("F:F")) Is Nothing Or _
Target.Count > 1 Then Exit Sub

Dim LR As Range

Set LR = Sheets(Target.Value).Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0)
Range(Cells(Target.Row, 1), Cells(Target.Row, 6)).Copy _
Destination:=LR

End Sub


Regards
Claus B.
 
C

Claus Busch

Hi again,

Am Wed, 9 Apr 2014 12:37:12 +0200 schrieb Claus Busch:
delete all code in the code modules of the worksheets.
Paste following code into the code module of "ThisWorkbook":

sorry, forgot to delete the entire row:

Private Sub Workbook_SheetChange(ByVal Sh As Object, _
ByVal Target As Range)
If Sh.Name = "Sheet7" Then Exit Sub

If Intersect(Target, Sh.Range("F:F")) Is Nothing Or _
Target.Count > 1 Then Exit Sub

Dim LR As Range

Set LR = Sheets(Target.Value).Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0)
Range(Cells(Target.Row, 1), Cells(Target.Row, 6)).Copy _
Destination:=LR
Target.EntireRow.Delete
End Sub


Regards
Claus B.
 
B

bojan0810

Why I made it so complicated lol

It works awesome, thank you very much for that.

Yesterday I was dying at macros and trying to figure it out why it doesnt work.

Thanks m8
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top