VBA to copy and paste special as value per condition

facedown12

New Member
Joined
Jun 4, 2015
Messages
2
Hi All,

I'm trying to create a macro to will select the entire row if it meets a condition as "Completed" in column b and paste it as values within the same row that it is currently in. I got it to work up to the copy stage, but having trouble pasting it, as my file is also protected with locked cells. I used this code from someone else online, but trying to modify it.

The reason I want this code to work, is because I don't want my formula in column b to keep changing once the condition has been met

Sub Copy_Paste()
Dim LastRowS As Long
Dim LastRowT As Long
'Assign variables for Current Sheet, Target Sheet and search string
cs = ActiveSheet.Name
Var1 = "Completed"
'Loop through all worksheets except listed
For Each wks In ActiveWorkbook.Worksheets
'Do this for all sheets except these
Select Case wks.Name
Case ts, "HG Wip"
'do nothing with the above worksheets
Case Else
'With worksheets not listed, do the following...
With wks
Sheets(wks.Name).Activate
LastRowS = Cells(Rows.Count, 4).End(xlUp).Row
Set Source = Range("B2:B" & LastRowS)
For Each c In Source
If c.Value = Var1 Then
'Copy Rows that meet Criteria
c.EntireRow.Copy
c.Enttirerow.PasteSpecial Paste:=Values


End If
Next c
End With
End Select
Next wks
Sheets(cs).Activate 'Return to Current Worksheet when done
'Clear memory
Set Source = Nothing
End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Forum statistics

Threads
1,222,227
Messages
6,164,722
Members
451,912
Latest member
HMF009

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