Copy/paste special values of Excel table based on cell value

stacey_t

New Member
Joined
Jan 12, 2024
Messages
4
Office Version
  1. 365
Platform
  1. Windows
I'm looking to create a macro that will copy/paste special values (remove formulas) in a table row based on the value in column A of that row being set to "Complete". I'm open to it being a button or automatic but I can't get that far... I tried using the code at this thread Macro to hardcode a row based on formula output but I am getting a Compile error: Argument not optional error.
Sub CopyPasteCompleted() Dim Cl As Range, Rng As Range On Error Resume Next Set Rng = Range("A:A").SpecialCells(xlFormulas) On Error GoTo 0 If Rng Is Nothing Then Exit Sub For Each Cl In Range If Cl.Value = "Complete" Then Cl.EntireRow.Value = Cl.EntireRow.Value End If Next Cl End Sub
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
There is an error in the code that was pointed out and corrected on the 2nd page of that thread.
This line:
VBA Code:
For Each Cl In Range
should be this:
VBA Code:
For Each Cl In Rng
 
Upvote 0
I can't figure out how to edit the original thread. The macro has been edited to

Sub formulatovalue()

ActiveSheet.Select
Dim c As Range
For Each c In Columns(1).SpecialCells(xlConstants)
If c.Value = "Complete " Then
c.EntireRow.Value = c.EntireRow.Value
End If
Next c

MsgBox "Done."

End Sub

Which does work but I'd like to incorporate a HasFormula condition to keep it from looping through every row of the worksheet every time. The last run took a while...
 
Upvote 0

Forum statistics

Threads
1,223,914
Messages
6,175,351
Members
452,638
Latest member
Oluwabukunmi

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