Vba to create a new excel file and convert all cell formulas to text

dbx

New Member
Joined
Apr 24, 2012
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'm trying to create VBA code that converts all current formulas in cells to text values and save the entire sheet to a new XLS file.
For this purpose I've used the following VBA code, but it doesn't do what I want. The newly created XLS file still contains formulas in the cells.

I would appreciate any idea how to fix it.

Sub SaveDialogFile()
Dim FilePath As String
Dim FilePathServer As String

FilePathServer = "\\Fileserver\2025\"

On Error Resume Next
Application.DisplayAlerts = False

With Sheets("Order")
If .Range("T9") = "" Then
MsgBox "Please enter ERP order number!"
.Activate
.Range("T9").Select

Exit Sub
End If
End With

With Application.FileDialog(msoFileDialogSaveAs)

Range("B4:C53").Copy
Range("B4:C53").PasteSpecial (xlPasteValues)

.Title = "Please choose a location and file name to save."
.ButtonName = "Save Deal File"
.InitialFileName = FilePathServer & Format(Now(), "yymmdd HhNn")
If .Show = 0 Then
MsgBox "File did not save!", vbCritical

Exit Sub
End If

Application.DisplayAlerts = False
.Execute
Application.DisplayAlerts = True

End With
End Sub
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
on your pastevalues line try changing it to this:
Range("B4:C53").PasteSpecial Paste:=xlPasteValues
 
Upvote 0

Forum statistics

Threads
1,226,460
Messages
6,191,164
Members
453,643
Latest member
adamb83

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