+ Reply to Thread
Results 1 to 9 of 9

Multiply with Formula to the existing cell values

Hybrid View

  1. #1
    Spammer
    Join Date
    06-27-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    183

    Thumbs up Multiply with Formula to the existing cell values

    Hi,

    I need to multiply the values of particular row with other row with formula link.

    Example values of 4th row to be multiply with row 2 & 3 with formula like in A2 cell "=A2 cell value * A4"

    If i change the value of A4, A2 & A3 also should change accordingly.

    I have attached excel workbook with sample data.

    Request you to help with VBA code.
    Attached Files Attached Files
    Last edited by prabhubox@yahoo.com; 07-19-2016 at 06:20 AM.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,863

    Re: Multiply with Formula to the existing cell values

    In Worksheet code:

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rng As Range
    If Not Intersect(Target, Rows(4)) Is Nothing Then
      For Each rng In Intersect(Target, Rows(4))
        If rng.Value <> 0 And IsNumeric(rng) Then
          Application.EnableEvents = False
          rng.Copy
          rng.Offset(-2, 0).Resize(2, 1).PasteSpecial operation:=xlPasteSpecialOperationMultiply
          Application.EnableEvents = True
        End If
      Next rng
      Application.CutCopyMode = False
      Target.Select
    End If
    End Sub
    Attached Files Attached Files
    Best Regards,

    Kaper

  3. #3
    Spammer
    Join Date
    06-27-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    183

    Re: Multiply with Formula to the existing cell values

    Hi kaper,

    I am unable to run the code as it is not showing in my macro list, request your help

  4. #4
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,863

    Re: Multiply with Formula to the existing cell values

    PS. note that to change it back, you need it inverted, so if you had
    100
    5
    and entered in row 4
    2

    you will have
    200
    10
    2

    now to change it back to
    100
    5
    you shall enter in row 4
    0.5
    or
    Formula: copy to clipboard
    =1/2

  5. #5
    Spammer
    Join Date
    06-27-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    183

    Re: Multiply with Formula to the existing cell values

    Thanks Kaper,

    As i'm using this code with the existing standard module, request your help to conver this code as standard madule to add with my program.

  6. #6
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,863

    Re: Multiply with Formula to the existing cell values

    of course one could add
    application.screenupdationg=false
    at the beginning and set it to True at the end od sub

  7. #7
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,863

    Re: Multiply with Formula to the existing cell values

    It is in a worksheet code, not in standard module.
    So you don't have to manually run it.

    just open the file, enable macros, change value in one of cells in row 4 (confirm change with enter) and see how cells in row 2 and 3 changes.

    This is how I understood your request:
    If i change the value of A4, A2 & A3 also should change accordingly.

  8. #8
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,863

    Re: Multiply with Formula to the existing cell values

    Sub Multiply_by_row_4()
    Dim rng As Range, Target As Range, storeselection as object
    set storeselection = selection
    Set target = activesheet.range("B4:CB4")
    'If Not Intersect(Target, Rows(4)) Is Nothing Then
    '  For Each rng In Intersect(Target, Rows(4))
      For Each rng In Target
        If rng.Value <> 0 And IsNumeric(rng) Then
    '      Application.EnableEvents = False
          rng.Copy
          rng.Offset(-2, 0).Resize(2, 1).PasteSpecial operation:=xlPasteSpecialOperationMultiply
    '     Application.EnableEvents = True
        End If
      Next rng
      Application.CutCopyMode = False
    '  Target.Select
    storeselection.select
    'End If
    End Sub
    Try the above in standard module

  9. #9
    Spammer
    Join Date
    06-27-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    183

    Re: Multiply with Formula to the existing cell values

    Thanks it is working!

    if you help with formula instead of special paste it will help in changing the numbers in row 4.

    I.e instead of changing numbers in column 3 & 2 if we give link like row 3 value * row 4 value ( as link) if i change row 4 the effect will be in row 3 & 2.

    PS. the existing formula in row 4 can be make it special paste. like my 1st attachment
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Multiply two cell values VBA Type Mismatch
    By prjt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-22-2015, 04:35 PM
  2. Formula to multiply values
    By hallaw81 in forum Excel General
    Replies: 34
    Last Post: 07-04-2014, 04:24 AM
  3. Replies: 11
    Last Post: 06-27-2014, 08:11 AM
  4. [SOLVED] Need help with existing macro to multiply results
    By velocitygraphix in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-05-2014, 11:31 AM
  5. Multiply Cells Which Have Values By a Formula
    By Jrub in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-11-2012, 11:02 AM
  6. Multiply cell values between 2 dates
    By mttlltt75 in forum Excel General
    Replies: 1
    Last Post: 01-14-2011, 04:14 PM
  7. Multiply values make up a cell answer
    By riyo91 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-05-2010, 05:56 AM

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