+ Reply to Thread
Results 1 to 7 of 7

Help with percent formula beginner

  1. #1
    Ted
    Guest

    Help with percent formula beginner

    Hi, have a cell (A1) with $39.99. I want a cell (B1) were I can vary
    10%, 20% etc and have that effect (A1). So If I put in 10% A1 would be
    $36.00 (percent decrease). Can you please help me out with the formula?

    Also it seems like if I type in % in a cell and I delete it and type
    another number and I don't want a % in there it gives it to me anyway.
    Can I make this stop?

    Thanks so much

    Ted


  2. #2
    Bob Phillips
    Guest

    Re: Help with percent formula beginner

    Private Sub Worksheet_Change(ByVal Target As Range)

    On Error GoTo ws_exit:
    Application.EnableEvents = False
    If Not Intersect(Target, Me.Range("B1")) Is Nothing Then
    With Target
    .Offset(0, -1).Value = Round(.Offset(0, -1).Value * (1 -
    ..Value), 2)
    End With
    End If

    ws_exit:
    Application.EnableEvents = True
    End Sub

    'This is worksheet event code, which means that it needs to be
    'placed in the appropriate worksheet code module, not a standard
    'code module. To do this, right-click on the sheet tab, select
    'the View Code option from the menu, and paste the code in.


    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Ted" <[email protected]> wrote in message
    news:[email protected]...
    > Hi, have a cell (A1) with $39.99. I want a cell (B1) were I can vary
    > 10%, 20% etc and have that effect (A1). So If I put in 10% A1 would be
    > $36.00 (percent decrease). Can you please help me out with the formula?
    >
    > Also it seems like if I type in % in a cell and I delete it and type
    > another number and I don't want a % in there it gives it to me anyway.
    > Can I make this stop?
    >
    > Thanks so much
    >
    > Ted
    >




  3. #3
    Ted
    Guest

    Re: Help with percent formula beginner

    Thanks, so quick too. It works! Although I need $39.99 to be constant.
    Like if I put 10% in it goes to $36.00. But if I put in 50% in place of
    and after 10% it goes to 18 instead of $20.00. Any ideas?

    Ted

    Bob Phillips wrote:
    > Private Sub Worksheet_Change(ByVal Target As Range)
    >
    > On Error GoTo ws_exit:
    > Application.EnableEvents = False
    > If Not Intersect(Target, Me.Range("B1")) Is Nothing Then
    > With Target
    > .Offset(0, -1).Value = Round(.Offset(0, -1).Value * (1 -
    > .Value), 2)
    > End With
    > End If
    >
    > ws_exit:
    > Application.EnableEvents = True
    > End Sub
    >
    > 'This is worksheet event code, which means that it needs to be
    > 'placed in the appropriate worksheet code module, not a standard
    > 'code module. To do this, right-click on the sheet tab, select
    > 'the View Code option from the menu, and paste the code in.
    >
    >
    > --
    >
    > HTH
    >
    > RP
    > (remove nothere from the email address if mailing direct)
    >
    >
    > "Ted" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi, have a cell (A1) with $39.99. I want a cell (B1) were I can vary
    > > 10%, 20% etc and have that effect (A1). So If I put in 10% A1 would be
    > > $36.00 (percent decrease). Can you please help me out with the formula?
    > >
    > > Also it seems like if I type in % in a cell and I delete it and type
    > > another number and I don't want a % in there it gives it to me anyway.
    > > Can I make this stop?
    > >
    > > Thanks so much
    > >
    > > Ted
    > >



  4. #4
    Bob Phillips
    Guest

    Re: Help with percent formula beginner

    Try this variation

    Private Sub Worksheet_Change(ByVal Target As Range)

    On Error GoTo ws_exit:
    Application.EnableEvents = False
    If Not Intersect(Target, Me.Range("B1")) Is Nothing Then
    With Target
    .Offset(0, -1).Value = 39.99* (1 - .Value), 2)
    End With
    End If

    ws_exit:
    Application.EnableEvents = True
    End Sub


    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Ted" <[email protected]> wrote in message
    news:[email protected]...
    > Thanks, so quick too. It works! Although I need $39.99 to be constant.
    > Like if I put 10% in it goes to $36.00. But if I put in 50% in place of
    > and after 10% it goes to 18 instead of $20.00. Any ideas?
    >
    > Ted
    >
    > Bob Phillips wrote:
    > > Private Sub Worksheet_Change(ByVal Target As Range)
    > >
    > > On Error GoTo ws_exit:
    > > Application.EnableEvents = False
    > > If Not Intersect(Target, Me.Range("B1")) Is Nothing Then
    > > With Target
    > > .Offset(0, -1).Value = Round(.Offset(0, -1).Value * (1 -
    > > .Value), 2)
    > > End With
    > > End If
    > >
    > > ws_exit:
    > > Application.EnableEvents = True
    > > End Sub
    > >
    > > 'This is worksheet event code, which means that it needs to be
    > > 'placed in the appropriate worksheet code module, not a standard
    > > 'code module. To do this, right-click on the sheet tab, select
    > > 'the View Code option from the menu, and paste the code in.
    > >
    > >
    > > --
    > >
    > > HTH
    > >
    > > RP
    > > (remove nothere from the email address if mailing direct)
    > >
    > >
    > > "Ted" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Hi, have a cell (A1) with $39.99. I want a cell (B1) were I can vary
    > > > 10%, 20% etc and have that effect (A1). So If I put in 10% A1 would be
    > > > $36.00 (percent decrease). Can you please help me out with the

    formula?
    > > >
    > > > Also it seems like if I type in % in a cell and I delete it and type
    > > > another number and I don't want a % in there it gives it to me anyway.
    > > > Can I make this stop?
    > > >
    > > > Thanks so much
    > > >
    > > > Ted
    > > >

    >




  5. #5
    Ted
    Guest

    Re: Help with percent formula beginner

    Hi, unfortunately receiving a compile error: Expected end of statement
    at the , before 2).

    Ted


  6. #6
    Bob Phillips
    Guest

    Re: Help with percent formula beginner

    Sorry, should have tested it.

    Private Sub Worksheet_Change(ByVal Target As Range)

    On Error GoTo ws_exit:
    Application.EnableEvents = False
    If Not Intersect(Target, Me.Range("B1")) Is Nothing Then
    With Target
    .Offset(0, -1).Value = Round(39.99 * (1 - .Value), 2)
    End With
    End If

    ws_exit:
    Application.EnableEvents = True
    End Sub

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Ted" <[email protected]> wrote in message
    news:[email protected]...
    > Hi, unfortunately receiving a compile error: Expected end of statement
    > at the , before 2).
    >
    > Ted
    >




  7. #7
    Ted
    Guest

    Re: Help with percent formula beginner

    Perfect! Thanks you so much. Your a life safer.

    Ted


+ 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