Convert Contents to Values VBA

dannyok90

Board Regular
Joined
Aug 30, 2016
Messages
115
Hi all,

Im looking to convert the formulas in some cells to values and then revert back to formulas?


Basically i have a save button that saves the file but i want the data to become static in the saved file some cells do have formulas that need to stay because they are looking at the now static data.


I have got this far which selects the cells:

Code:
Union(Cells(1, "A"), Cells(4, "A"), Cells(7, "A"), Cells(5, "E"), Cells(7, "E"), Cells(5, "K"), Cells(7, "K"), Cells(11, "Q"), Cells(13, "Q"), Cells(15, "Q"), Cells(19, "Q")).Select


Heres the full code for context:

Code:
Option Explicit
Sub SaveAsExample()
 
    Dim FName           As String
    Dim FPath           As String
    
    FPath = "T:\V-Task\V0000+\200+\V0297\Shared\Project Status Report (PSR)\PSRs"
    FName = Sheets("Sheet1").Range("A9") & ".xlsm"

With Union(Cells(1, "A"), Cells(4, "A"), Cells(7, "A"), Cells(5, "E"), Cells(7, "E"), Cells(5, "K"), Cells(7, "K"), Cells(11, "Q"), Cells(13, "Q"), Cells(15, "Q"), Cells(19, "Q")).Select
     
End With
 With ActiveWorkbook
 
     Columns("U:W").EntireColumn.Hidden = True
     ActiveSheet.Range("C10").Select
   .SaveCopyAs Filename:=FPath & "\" & FName
    Columns("U:W").EntireColumn.Hidden = False
End With
     
End Sub
Thanks in advance :D
Dan
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
How about
Code:
For Each Cl In Union(Cells(1, "A"), Cells(4, "A"), Cells(7, "A"), Cells(5, "E"), Cells(7, "E"), Cells(5, "K"), Cells(7, "K"), Cells(11, "Q"), Cells(13, "Q"), Cells(15, "Q"), Cells(19, "Q"))
   Cl.Value = Cl.Value
Next Cl
 
Upvote 0
How about
Code:
For Each Cl In Union(Cells(1, "A"), Cells(4, "A"), Cells(7, "A"), Cells(5, "E"), Cells(7, "E"), Cells(5, "K"), Cells(7, "K"), Cells(11, "Q"), Cells(13, "Q"), Cells(15, "Q"), Cells(19, "Q"))
   Cl.Value = Cl.Value
Next Cl

Thanks Fluff!

what type of variable is "cl"

Dan
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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