F
Frick
Thanks to JE McGimpsey for the script code below that solved a problem
that I had with working with currency rates.
The script works great but I have encountered one problem that is when
I have added some columns and rows which in effect moves the range
from A5:C15 to C9:E14. I changed the range in the script but it
failed to work.
I guess I must be missing something here, so any help would be
appreciated.
Thank you.
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim rateRange As Range
Dim temp As Double
With Target
If .Count > 1 Then Exit Sub
If Not Intersect(.Cells, Range("A5:C15")) Is Nothing Then
Set rateRange = Range("A2:C2")
Application.EnableEvents = False
temp = .Value / rateRange(.Column)
With Cells(.Row, 1).Resize(1, 3)
Select Case Target.Column
Case 1
.Item(2).Value = temp * rateRange(2)
.Item(3).Value = temp * rateRange(3)
Case 2
.Item(1).Value = temp * rateRange(1)
.Item(3).Value = temp * rateRange(3)
Case Else
.Item(1).Value = temp * rateRange(1)
.Item(2).Value = temp * rateRange(2)
End Select
End With
Application.EnableEvents = True
End If
End With
End Sub
that I had with working with currency rates.
The script works great but I have encountered one problem that is when
I have added some columns and rows which in effect moves the range
from A5:C15 to C9:E14. I changed the range in the script but it
failed to work.
I guess I must be missing something here, so any help would be
appreciated.
Thank you.
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim rateRange As Range
Dim temp As Double
With Target
If .Count > 1 Then Exit Sub
If Not Intersect(.Cells, Range("A5:C15")) Is Nothing Then
Set rateRange = Range("A2:C2")
Application.EnableEvents = False
temp = .Value / rateRange(.Column)
With Cells(.Row, 1).Resize(1, 3)
Select Case Target.Column
Case 1
.Item(2).Value = temp * rateRange(2)
.Item(3).Value = temp * rateRange(3)
Case 2
.Item(1).Value = temp * rateRange(1)
.Item(3).Value = temp * rateRange(3)
Case Else
.Item(1).Value = temp * rateRange(1)
.Item(2).Value = temp * rateRange(2)
End Select
End With
Application.EnableEvents = True
End If
End With
End Sub