Results 1 to 5 of 5

Need to get values based on multiple conditions through Macro

Threaded View

  1. #1
    Registered User
    Join Date
    06-10-2023
    Location
    Mumbai India
    MS-Off Ver
    2019
    Posts
    21

    Need to get values based on multiple conditions through Macro

    So far my code is working OK however I dont seem to be getting desired values since all the values are dynamic and change from time to time, hence the need for change, I need to embed this in my code, I have no idea how to acheive it. I need these values only when column D & J is clicked.

    Formula: copy to clipboard
    =IF(H47<=90,G7-(H47*M47)*5%,
    IF(H47<=80,G47-(H47*M47)*6%,
    IF(H47<=70,G47-(H47*M47)*8%,
    IF(H47<=65,G47-(H47*M47)*11%,
    IF(H47<=60,G47-(H47*M47)*14%,
    IF(H47<=55,G47-(H47*M47)*17%,
    IF(H47<=50,G47-(H47*M47)*19%,
    IF(H47<=40,G47-(H47*M47)*22%,
    IF(H47<=30,G47-(H47*M47)*25%,
    ))))))))


    =IF(A47<=90,G47+(F47*A47)*5%,
    IF(A47<=80,G47+(F47*A47)*6%,
    IF(A47<=70,G47+(F47*A47)*8%,
    IF(A47<=65,G47+(F47*A47)*11%,
    IF(A47<=60,G47+(F47*A47)*14%,
    IF(A47<=55,G47+(F47*A47)*17%,
    IF(A47<=50,G47+(F47*A47)*19%,
    IF(A47<=40,G47+(F47*A47)*22%,
    IF(A47<=30,G47-(F47*A47)*25%,
    ))))))))

    Current Code in use which doesnt give desired values:

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Column <> 4 And Target.Column <> 10 Then Range("A3,M3").ClearContents
    
    If Intersect(Target, Range("J4:J76,D4:D76")) Is Nothing Or Target.Count > 1 Then Exit Sub
    
    With Target
        Select Case .Column
            Case [J1].Column
                G = .Offset(, -3).Value
                H = .Offset(, -2).Value
                M = .Offset(, 3).Value
                [M3].Value = WorksheetFunction.MRound(G - (H * M) * 0.1, 0.05)
                
            Case [D1].Column
                G = .Offset(, 3).Value
                A = .Offset(, -3).Value
                F = .Offset(, 2).Value
                [A3].Value = WorksheetFunction.MRound(G + (A * F) * 0.1, 0.05)
                            
        End Select
    End With
    Attached Files Attached Files
    Last edited by mahmad558; 06-16-2023 at 10:30 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Looking up values based on multiple conditions then put sum the values in anther sheet.
    By cuchi33 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-05-2017, 11:35 AM
  2. Replies: 1
    Last Post: 10-01-2013, 02:41 AM
  3. Replies: 5
    Last Post: 09-25-2013, 12:31 AM
  4. [SOLVED] Formula to get look up values based on multiple conditions
    By Excel Dumbo in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-29-2013, 12:17 AM
  5. [SOLVED] Trying to add conditioning and values based on multiple conditions.
    By SadenShard in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-27-2011, 12:58 AM
  6. Insert multiple values from seperate table based on multiple conditions
    By drakesong in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-28-2011, 06:04 PM
  7. Calculate Values based on Multiple Conditions
    By creativefusion in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 05-24-2009, 09:27 PM

Tags for this Thread

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