I have this code:
It is a simple dynamic conversion tool. Whereas in Excel, we usually have one input cell and one output cell. Through this code, both input cells are also output cells. I.E. Converting Dollar to Peso or Peso to Dollar, Meter to Inches or Inches to Meter....![]()
Private Sub Worksheet_Change(ByVal Target As Range) Const WS_Range As String = "b9:c9" Dim iColumn As Integer Application.EnableEvents = False Application.ScreenUpdating = False On Error Resume Next If Not Intersect(Target, Me.Range(WS_Range)) Is Nothing Then iColumn = Target.Column If iColumn = 3 Then Range("b9").Value = Range("c9").Value / Range("b13").Value Else: Range("c9").Value = Range("b9").Value * Range("b13").Value End If End If Application.EnableEvents = True Application.ScreenUpdating = True On Error GoTo 0 End Sub
Problem is, this code only specifies two specific cells, namely b9 and c9 with b13 as the conversion factor. How can I expand the code to include multiple pairs of cells. I.E. A1:B1, C10:C11,etc by 1) Using the same 'conversion factor' cell (b13) and 2) Using different conversion factors located in different cells on the worksheet.
Many thanks,
lex
Bookmarks