Change code to include other targeted cells

Av8tordude

Well-known Member
Joined
Oct 13, 2007
Messages
1,038
I have the code below that multiplies the number entered in row 42 by 3.65 (starting from column B). I would like the code to be able to do the same for each cell that I'm currently targeted in row 42. It should not multiply the entire row 42. Only the targeted cell in row 42

Code:
    If Intersect(Target, Range("B42:IV42")) Is Nothing Then Application.EnableEvents = True: Exit Sub
    If Target.Offset(0, -1) = "IBQ Credit Card" Then
        Target.Value = Round(Target.Value * 3.65, 2)
    End If
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

JustynaMK

Well-known Member
Joined
Aug 28, 2016
Messages
674
Office Version
  1. 365
  2. 2013
Platform
  1. Windows
Hey Av8tordude,
Just to clarify - how exactly would you like your code to work? For example, would you like to select a cell (range of cells), hit a keyboard shortcut, and have these cells multiplied by 3.65?
 
Upvote 0

svendiamond

Well-known Member
Joined
Jun 13, 2014
Messages
1,504
Office Version
  1. 365
Platform
  1. Windows
^^ what he said. Or do you want to utilize the double-click event?
 
Upvote 0

Av8tordude

Well-known Member
Joined
Oct 13, 2007
Messages
1,038
solve my own puzzle....thanks

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    If Intersect(Target, Range("B42:IV42")) Is Nothing Then Application.EnableEvents = True: Exit Sub
    Target.Value = Round(Target.Value * 3.65, 2)
    Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,191,557
Messages
5,987,269
Members
440,087
Latest member
Ruppert23

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
Top