Hi all

I've added a currency converter (as a pop-up userform) to one of my existing macros. At first I only used 1 base value (eg. it could only convert USD -> EUR, not the other way). Now I would like to make it go both ways - and I have 5 different currencies.

What I thought would work is this;

VB Code:
  1. Private Sub CommandButton1_Click()
  2. Dim x As Long
  3. Dim i As Long
  4. Dim j As Long
  5. Dim vSheet As Worksheet
  6. Dim dSheet As Worksheet
  7. Dim oOption As MSForms.OptionButton
  8.  
  9. Set vSheet = ActiveWorkbook.Worksheets("Valuta")
  10. Set dSheet = ActiveWorkbook.Worksheets("Data")
  11.  
  12. Application.ScreenUpdating = False
  13.  
  14. For Each oOption In FrmCur.Frame1
  15.     With oOption
  16.         If .Value = True Then
  17.             For x = 2 To 6
  18.                 If Opt1.Caption = vSheet.Cells(x, 1).Value Then
  19.                 With vSheet
  20.                     For i = 6 To dSheet.Cells(1, 5).End(xlToRight).Column
  21.                     If Not Right(.Cells(1, i).Value, 3) = "pct" Then
  22.                                 vSheet.Activate
  23.                                 vSheet.Cells(x, 2).Copy
  24.                                 dSheet.Activate
  25.                                 dSheet.Range(Cells(2, i), Cells(2, i).End(xlDown)).PasteSpecial Paste:=xlValues, operation:=xlMultiply
  26.                                
  27.                     End If
  28.                     Next i
  29.                 End With
  30.                 End If
  31.             Next x
  32.         End If
  33.     End With
  34. Next oOption
  35.  
  36. For Each oOption In FrmCur.Frame2
  37.     With oOption
  38.         If .Value = True Then
  39.             For x = 2 To 6
  40.                 If Opt1.Caption = vSheet.Cells(x, 1).Value Then
  41.                 With vSheet
  42.                     For i = 6 To dSheet.Cells(1, 5).End(xlToRight).Column
  43.                     If Not Right(.Cells(1, i).Value, 3) = "pct" Then
  44.                                 vSheet.Activate
  45.                                 vSheet.Cells(x, 2).Copy
  46.                                 dSheet.Activate
  47.                                 dSheet.Range(Cells(2, i), Cells(2, i).End(xlDown)).PasteSpecial Paste:=xlValues, operation:=xlDivide
  48.                                
  49.                     End If
  50.                     Next i
  51.                 End With
  52.                 End If
  53.             Next x
  54.         End If
  55.     End With
  56. Next oOption
  57.  
  58. FrmCur.Hide
  59.  
  60. Application.ScreenUpdating = True
  61.  
  62. End Sub

However this line;
VB Code:
  1. For Each oOption In FrmCur.Frame2
is giving me problems. I know I can use it on a spreadsheet (browsing OLEObjects) - so can't I also use in a userform?

Any thoughts are welcome