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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
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,224,830
Messages
6,181,229
Members
453,026
Latest member
cknader

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