macro to convert formulas to values for data not consecutative

SHough

New Member
Joined
Feb 24, 2011
Messages
2
I have an Excel workbook with many tabs and each tab contains a similar formula in every 5th column. For these tabs I want to convert this particular formula for a very specific range on each tab from a formula to a value.

I would like to create a macro that finds every cell that contains the letters "Assumptions!$" (omit the quotes) and replace that cell with its value, then continue on to find the next cell that meets this criteria. I want this macro to only run for the range actually selected. I need to limit this to only the range selected because I have hidden rows below any particular range that need to retain this formula.

I can not use the paste special command because the cells are not contiguous.

Any ideas out here?
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
At a guess:
Code:
For Each c in Selection
   InStr(1, c.Formula, "Assumptions!$") > 0 Then
      c.Value=c.Value
   End If
Next
 
Upvote 0
Thank you!!

I needed to add an 'If' parameter to the front end of the InStr...:

Sub Turn_Off_PY_to_CY()
For Each c In Selection
If InStr(1, c.Formula, "Assumptions!$") > 0 Then
c.Value = c.Value
End If
Next
End Sub

But it works perfectly !!

Saving me hours of work. My own IT department did not come up with the answer.

SHough
 
Upvote 0
My pleasure. I'm glad you spotted my mistake ... I'd guessed the code in my head, so it wasn't really checked.

It sounds like you're saving a lot of time by using the macro ... that's great! :-D
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,906
Members
452,366
Latest member
TePunaBloke

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