Hi all,
I am trying to create a macro to copy and paste Values and formatting In Columns M, O, AA:AE when column AF = "Y".
I have tried the following but i doesn't work.
I'd appreciate any help.
Thanks
Option Explicit
Sub PasteContitionalSpecial()
Dim lastrow As Long, r As Long
With ThisWorkbook.ActiveSheet
lastrow = .Range("AF" & .Rows.Count).End(xlUp).Row
For r = 2 To lastrow
If .Range("AF" & r).Value = "Y" Then
.Range("M" & r).Value = .Range("M" & r).Value
End If
Next r
End With
End Sub
I'm wondering if some variation of the following could work but everything I try fails.
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified 2/22/2020 11:42:10 AM EST
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Column = 31 Then
Dim Lastrow As Long
Lastrow = Sheets("Open").Cells(Rows.Count, 13).End(xlUp).Row + 1
Dim ans As Long
ans = Target.Row
If Target.Value = "Y" Then
Rows(ans).Copy Sheets("open").Rows(Lastrow)
End If
End If
End Sub
I am trying to create a macro to copy and paste Values and formatting In Columns M, O, AA:AE when column AF = "Y".
I have tried the following but i doesn't work.
I'd appreciate any help.
Thanks
Option Explicit
Sub PasteContitionalSpecial()
Dim lastrow As Long, r As Long
With ThisWorkbook.ActiveSheet
lastrow = .Range("AF" & .Rows.Count).End(xlUp).Row
For r = 2 To lastrow
If .Range("AF" & r).Value = "Y" Then
.Range("M" & r).Value = .Range("M" & r).Value
End If
Next r
End With
End Sub
I'm wondering if some variation of the following could work but everything I try fails.
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified 2/22/2020 11:42:10 AM EST
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Column = 31 Then
Dim Lastrow As Long
Lastrow = Sheets("Open").Cells(Rows.Count, 13).End(xlUp).Row + 1
Dim ans As Long
ans = Target.Row
If Target.Value = "Y" Then
Rows(ans).Copy Sheets("open").Rows(Lastrow)
End If
End If
End Sub