dilligaf5298
New Member
- Joined
- Sep 19, 2012
- Messages
- 4
Group, this is my first time posing a question, so please forgive my ineptitude.
I have workbook that has 43 sheets and it's used to calculate accident reconstruction formulas. Sheet 1 is for Coefficient of Friction; Sheet 18 is for Speed Change in a Collision; etc. My goal is to be able to enter a value for a needed variable in imperial in a cell, but have that same value converted to its metric equivalent in a companion cell automatically. If i enter the metric value, the imperial equivalent is automatically calculated and displayed.
I've written a macro designed to be used only on the active worksheet that is listed as "Selection Change", as the entry cells are not the same on each sheet. For instance, it includes:
With ActiveSheet
Depending on the number of variables for that sheet, there are more iterations of the above, but tailored to address whatever cell value is used (the example shown converts weight from pounds to kilograms).
This macro will work on Sheet 18 without problem. When copied to Sheet 1 module (or others) with the cell addresses and conversion values corrected, it won't work. On each sheet module, the macro is classified as "Worksheet" and "SelectionChange". I'm using Office 365 (latest) and Windows 10. The name listed for each module window in VBA is "Sheet 1 [or as appropriate] (Code)" and the initial lines of the macro are "Private Sub Worksheet_SelectionChange (ByVal Target As Range)" followed by "Application.EnableEvents = False" on the second line. The EnableEvents returns to "True" immediately before the "End Sub"
I'll be glad to paste the macro in if I can figure out how to do that correctly.
Thank you in advance for your tolerance, help, and most importantly, all the help I've gleaned from this forum over the years.
I have workbook that has 43 sheets and it's used to calculate accident reconstruction formulas. Sheet 1 is for Coefficient of Friction; Sheet 18 is for Speed Change in a Collision; etc. My goal is to be able to enter a value for a needed variable in imperial in a cell, but have that same value converted to its metric equivalent in a companion cell automatically. If i enter the metric value, the imperial equivalent is automatically calculated and displayed.
I've written a macro designed to be used only on the active worksheet that is listed as "Selection Change", as the entry cells are not the same on each sheet. For instance, it includes:
With ActiveSheet
If Target = .[F4] Then
.[G4].Value = .[F4].Value * 2.2046
ElseIf Target = .[G4] Then
.[F4].Value = .[G4]. Value / 2.2046
ElseIf Target = .[G4] Then
.[F4].Value = .[G4]. Value / 2.2046
End If
End With
Depending on the number of variables for that sheet, there are more iterations of the above, but tailored to address whatever cell value is used (the example shown converts weight from pounds to kilograms).
This macro will work on Sheet 18 without problem. When copied to Sheet 1 module (or others) with the cell addresses and conversion values corrected, it won't work. On each sheet module, the macro is classified as "Worksheet" and "SelectionChange". I'm using Office 365 (latest) and Windows 10. The name listed for each module window in VBA is "Sheet 1 [or as appropriate] (Code)" and the initial lines of the macro are "Private Sub Worksheet_SelectionChange (ByVal Target As Range)" followed by "Application.EnableEvents = False" on the second line. The EnableEvents returns to "True" immediately before the "End Sub"
I'll be glad to paste the macro in if I can figure out how to do that correctly.
Thank you in advance for your tolerance, help, and most importantly, all the help I've gleaned from this forum over the years.