VBA Paste Special as Value

coolkat99

New Member
Joined
Mar 14, 2018
Messages
3
Hi
I dont have experience of VBA but have a code which moves a row of data from a worksheet called Report to a worksheet called Archived based on column Q = Yes. I want the code to paste the value into worksheet Archived as a value so that it removes any formulas from the data. How can I amend the code to make this happen. My code is shown below. Many thanks Will
Module 1
Sub archive()
Dim i, lastrow
Dim mytext As String
lastrow = Sheets("Report").Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To lastrow
mytext = Sheets("Report").Cells(i, "Q").Text
If InStr(mytext, "Yes") Then
Sheets("Report").Cells(i, "A").EntireRow.Copy Destination:=Sheets("Archived").Range("A" & Rows.Count).End(xlUp).Offset(1)
Sheets("Report").Cells(i, "A").EntireRow.Delete
End If
Next i

End Sub



Sheet 1 (Report)
Private Sub Worksheet_Change(ByVal Target As Range)
'Application.EnableEvents = False
'If Target.Column = 17 And UCase(Target) = "YES" Then
'Cells(Target.Row, Target.Column).EntireRow.Copy Destination:=Sheets("Archived").Range("A" & Rows.Count).End(xlUp).Offset(1)
'End If
'Application.EnableEvents = True





End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
What's the last column with data?
 
Upvote 0
Ok, try this
Code:
Sub archive()
   Dim i As Long, lastrow As Long
   
   With Sheets("Report")
      lastrow = .Range("A" & Rows.Count).End(xlUp).Row
      
      For i = lastrow To 2 Step -1
         If LCase(.Range("Q" & i).Value) = "yes" Then
            Sheets("Archived").Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(, 17).Value = .Range("A" & i).Resize(, 17).Value
            .Cells(i, "A").EntireRow.Delete
         End If
      Next i
   End With
End Sub
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,874
Messages
6,122,036
Members
449,062
Latest member
mike575

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