arun_ajay2000
04-09-2012, 05:35 AM
Hi,
Hi, Im new to VB programming. can anyone help me out to convert given VBA code to vb.net. this function is designed to convert all excel workbook data to value using pastespecial function.
Thank you in advance.
Sub ConvertAllToValues()
'
'Originally Adapted from OZgrid.com
'
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
Next
Set OldSelection = Selection.Cells
Worksheets.Select
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues
Cells(OldSelection.Row, OldSelection.Column).Select
Sheets(OldSelection.Worksheet.Name).Select
Application.CutCopyMode = False
For i = 1 To n
Sheets(i).Visible = Not HiddenSheets(i)
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End If
End Sub
Hi, Im new to VB programming. can anyone help me out to convert given VBA code to vb.net. this function is designed to convert all excel workbook data to value using pastespecial function.
Thank you in advance.
Sub ConvertAllToValues()
'
'Originally Adapted from OZgrid.com
'
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
Next
Set OldSelection = Selection.Cells
Worksheets.Select
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues
Cells(OldSelection.Row, OldSelection.Column).Select
Sheets(OldSelection.Worksheet.Name).Select
Application.CutCopyMode = False
For i = 1 To n
Sheets(i).Visible = Not HiddenSheets(i)
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End If
End Sub