+ Reply to Thread
Results 1 to 2 of 2

Macro to edit a formula.

Hybrid View

  1. #1
    jimwood
    Guest

    Macro to edit a formula.

    I have an old lotus macro that I would like to reproduce in excel.
    Specifically I would like to have a macro open a cell in an edit mode and
    have the cell be a formula of =round(/1.08,2) with the cursor sitting
    just in front of the division sign so that someone could enter a number and
    have it divide by 1.08. I and a coworker have been trying all sorts of
    things but none of them are working.
    --
    Thanks,
    Jim

  2. #2
    Dave Peterson
    Guest

    Re: Macro to edit a formula.

    This seemed to work ok for me:

    Option Explicit
    Sub testme01()

    Dim myRng As Range
    Dim myCell As Range

    Set myRng = Selection

    For Each myCell In myRng.Cells
    With myCell
    If .HasFormula Then
    .Formula = "=round((" & Mid(.Formula, 2) & ")/1.08,2)"
    Else
    .Formula = "=round(" & .Value & "/1.08,2)"
    End If
    End With
    Next myCell
    End Sub


    Select your range and test it out. It does all the cells that are selected.

    jimwood wrote:
    >
    > I have an old lotus macro that I would like to reproduce in excel.
    > Specifically I would like to have a macro open a cell in an edit mode and
    > have the cell be a formula of =round(/1.08,2) with the cursor sitting
    > just in front of the division sign so that someone could enter a number and
    > have it divide by 1.08. I and a coworker have been trying all sorts of
    > things but none of them are working.
    > --
    > Thanks,
    > Jim


    --

    Dave Peterson

+ 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