worksheet_selection change with formula

nidhipatel

Board Regular
Joined
Feb 11, 2017
Messages
52
when i enter a value in any cell of Range A2:A6 and B2:B6 then out put (multiplication of Range A2:A6 and B2:B6) will be shown in C2:C6
i do this only by worksheet selection change event by macro ex.

when i input value in "A2" and "B2" then out put show in "C2" or when i enter any value in "A3" and "B3" then output show in "C3". then respectively other cell.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
confused why you need to do it via a macro. Also confused as to what your actual issue is.
 
Upvote 0
Try this in the sheet module.

Howard

Code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A2:B6")) Is Nothing Then Exit Sub

Dim OneRng As Range

Set OneRng = Range(Cells(2, 3), Cells(6, 3))

    With OneRng
      .Formula = "=A2*B2"
      .Value = .Value
    End With

End Sub
 
Upvote 0
problem is when i enter value in A2 and B2 then output shown only in C2 or when i enter value A3 and B3 then output show in C3 only other wise nothing not "zero"
 
Upvote 0
i create a invoice when i enter value in "qty" heading like "A2" and heading "Rate" like "B2" then output show only heading "Total" like "C2" condition is when i enter data in rang then show output. understand
 
Upvote 0
Maybe this?

Howard

Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A2:B6")) Is Nothing Then Exit Sub

Dim OneRng As Range

Set OneRng = Range(Cells(2, 3), Cells(6, 3))

    With OneRng
      .Formula = "=IFERROR(IF(A2*B2=0,"""",A2*B2),"""")"
      .Value = .Value
    End With
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,432
Messages
6,119,468
Members
448,900
Latest member
Fairooza

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top