Consulting

Results 1 to 3 of 3

Thread: Increase Target.Value By Percentage

  1. #1
    VBAX Expert
    Joined
    Feb 2010
    Posts
    696
    Location

    Increase Target.Value By Percentage

    I thought this was going to be simple but I continue to receive an "Expected Expression" error. What I'm attempting to do is test for whether the Target contains a formula and if so to automatically adjust the Target.Value by 109.5%.

    [VBA]
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.HasFormula Then
    Application.EnableEvents = False
    Target.Value = Target.Value = (Target.Value * 109.5%)
    Application.EnableEvents = True
    End If

    End Sub
    [/VBA]

    Why would this not work? Is there a work-around to make accomplish the same objective?

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You do realise this will erase the formula?

    Private Sub Worksheet_Change(ByVal Target As Range)
        If Target.HasFormula Then
            Application.EnableEvents = False
            Target.Value = Target.Value * 2.095
            Application.EnableEvents = True
        End If
    End Sub
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Expert
    Joined
    Feb 2010
    Posts
    696
    Location
    Indeed I do. That is my objective. The formula is only needed for one-time data entry purposes in this application...once the results of the formula has been increased by the desired percentage, it's the value that I want to retain. Thanks for the help!

Posting Permissions

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