Hi Everyone,
I am new to Macros and am working on putting some macros in place for a spreadsheet that I am creating. I basically want to be able to Cut and delete the contents of a row if a certain cell says "Yes," and move the row into the next empty row of another sheet. So far I've gotten the row to Copy and Paste, but every time I try to add the Cut and Delete functionality I get an error message. Can anyone help me with this? The Code I am using that works is below:
Sub LetterMoveYes()
'
' LetterMoveYes Macro
' Move to Letters Tab if Letter Needs to be Mailed
'
' Keyboard Shortcut: Ctrl+Shift+M
'
Dim c As Long
Dim wsD As Worksheet: Set wsD = Worksheets("Master") 'Data Worksheet.
Dim wsR As Worksheet: Set wsR = Worksheets("Letters") 'Results Worksheet
For c = 2 To 25000 'Loop through 25000 records.
With wsD.Range("AM" & c)
If .Value = "Yes" Then
wsD.Range("A" & c & ":AQ" & c & "").Copy
wsR.Activate
wsR.Range("A" & wsR.Range("A" & Rows.Count).End(xlUp).Row + 1).Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
End With
Next c
End Sub
I'd really appreciate if someone could help me to figure out how to modify it so that the row actually cuts and deletes (in the Master sheet) rather than just copy and pasting and remaining there.
Thanks!
I am new to Macros and am working on putting some macros in place for a spreadsheet that I am creating. I basically want to be able to Cut and delete the contents of a row if a certain cell says "Yes," and move the row into the next empty row of another sheet. So far I've gotten the row to Copy and Paste, but every time I try to add the Cut and Delete functionality I get an error message. Can anyone help me with this? The Code I am using that works is below:
Sub LetterMoveYes()
'
' LetterMoveYes Macro
' Move to Letters Tab if Letter Needs to be Mailed
'
' Keyboard Shortcut: Ctrl+Shift+M
'
Dim c As Long
Dim wsD As Worksheet: Set wsD = Worksheets("Master") 'Data Worksheet.
Dim wsR As Worksheet: Set wsR = Worksheets("Letters") 'Results Worksheet
For c = 2 To 25000 'Loop through 25000 records.
With wsD.Range("AM" & c)
If .Value = "Yes" Then
wsD.Range("A" & c & ":AQ" & c & "").Copy
wsR.Activate
wsR.Range("A" & wsR.Range("A" & Rows.Count).End(xlUp).Row + 1).Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
End With
Next c
End Sub
I'd really appreciate if someone could help me to figure out how to modify it so that the row actually cuts and deletes (in the Master sheet) rather than just copy and pasting and remaining there.
Thanks!