Sub Copy_If_S_Or_V()
'Modified 5/9/2022 10:37:54 PM EDT
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "B").End(xlUp).Row
For i = 1 To Lastrow
Select Case Cells(i, 2).Value
Case "S", "V": Cells(i, "G").Copy Cells(i, "J")
End Select
Next
Application.ScreenUpdating = True
End Sub
Hi,Try this:
VBA Code:Sub Copy_If_S_Or_V() 'Modified 5/9/2022 10:37:54 PM EDT Application.ScreenUpdating = False Dim i As Long Dim Lastrow As Long Lastrow = Cells(Rows.Count, "B").End(xlUp).Row For i = 1 To Lastrow Select Case Cells(i, 2).Value Case "S", "V": Cells(i, "G").Copy Cells(i, "J") End Select Next Application.ScreenUpdating = True End Sub
Pastespecial has a lot of possibilitiesWell, if the script worked on one worksheet but not on another.
It's not because of my script.
You must have things laid out differently on other sheet
And I do not understand this:
I tried on other spreadsheet it doesn't work due to the cap between data as show below.
what is cap?
And why Pastespecial
Sub Copy_If_S_Or_V()
'Modified 5/10/2022 9:11:09 PM EDT
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Lastrow = Sheet2.Cells(Rows.Count, "B").End(xlUp).Row
With Sheet2
For i = 1 To Lastrow
Select Case .Cells(i, 2).Value
Case "S", "V": .Cells(i, "J").Value = .Cells(i, "G").Value
End Select
Next
End With
Application.ScreenUpdating = True
End Sub