+ Reply to Thread
Results 1 to 2 of 2

How to restore pre-macro values?

  1. #1
    Registered User
    Join Date
    06-24-2010
    Location
    Geneva
    MS-Off Ver
    Excel 2007
    Posts
    4

    Exclamation How to restore pre-macro values?

    Hi all,


    I have modified a macro found on Internet for converting some values into another currency.
    However, I would like to find a way to restore the previous values. How should I do?

    The macro for conversion is the following:


    Sub ConvertitoreRUR()

    Dim Formato, TipoVal, cambioEU, Intervallo, mObj As Range

    ' *** Parametri Valuta e Cambio Euro ***
    TipoVal = "RUR"
    cambioEU = 30.27
    Formato = "#,### $"
    ' **************************************

    ActiveSheet.Range("A1").Select
    Set Intervallo = Range(Cells(1, 1), Cells.SpecialCells(xlCellTypeLastCell))
    For Each mObj In Intervallo
    If Not IsEmpty(mObj) Then
    If IsNumeric(mObj.Value) Then
    If (mObj.Style = "Currency") Or (InStr(mObj.NumberFormatLocal, TipoVal) > 0) Then
    form = mObj.NumberFormatLocal
    n = InStr(form, TipoVal)
    If n > 0 Then
    mObj.NumberFormatLocal = Left(form, n - 1) + "$" + Right(form, Len(form) - n - 1)
    If mObj.HasFormula = True Then mObj.Value = mObj.Value / cambioEU
    End If
    form = mObj.NumberFormatLocal
    n = InStr(form, TipoVal)
    If n > 0 Then
    mObj.NumberFormatLocal = Left(form, n - 1) + "$" + Right(form, Len(form) - n - 1)
    End If
    If (mObj.Style = "Currency") Or (InStr(mObj.NumberFormatLocal, "$") > 0) Then mObj.NumberFormatLocal = Formato
    End If
    End If
    End If
    Next
    MsgBox "Currency conversion " & TipoVal & " ->" & " $" & " completed!", vbInformation + vbOKOnly, "by xxx"
    End Sub

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: How to restore pre-macro values?

    Hi minerva87

    Please wrap your code in code tags, before the moderators get you...

    Forum rules
    3. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # button at the top of the post window. If you are editing an existing post, press Go Advanced to see the # button.

    Cheers

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1