paste special function in convert VBA to

04-09-2012, 05:35 AM
Hi, Im new to VB programming. can anyone help me out to convert given VBA code to this function is designed to convert all excel workbook data to value using pastespecial function.
Thank you in advance.

Sub ConvertAllToValues()
'Originally Adapted from
Dim OldSelection As Range
Dim HiddenSheets() As Boolean
Dim Goahead As Integer, n As Integer, i As Integer
Goahead = MsgBox("This will irreversibly convert all formulas in the workbook to values. Continue?", vbOKCancel, "Confirm conversion to values only")
If Goahead = vbOK Then
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

n = Sheets.Count
ReDim HiddenSheets(1 To n) As Boolean

For i = 1 To n
If Sheets(i).Visible = False Then HiddenSheets(i) = True
Sheets(i).Visible = True

Set OldSelection = Selection.Cells
Selection.PasteSpecial Paste:=xlPasteValues

Cells(OldSelection.Row, OldSelection.Column).Select

Application.CutCopyMode = False

For i = 1 To n
Sheets(i).Visible = Not HiddenSheets(i)

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End If
End Sub

Cerian Knight
04-09-2012, 09:52 AM
This code is native VBA, which Excel uses directly. Therefore, confirm that you are trying to automate Excel using VB.NET? Also, show us what you have tried, since it is not the intent of this forum to do complete code-conversions for you.

BTW: I split this out to its own thread (and removed a duplicate post in another thread), since it did not see any relevance to the thread topic you had posted in. Please have a look at our ... when you have a chance. Thanks and welcome to the forum.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum