direktoren
Jul 3rd, 2006, 06:36 AM
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;
Private Sub CommandButton1_Click()
Dim x As Long
Dim i As Long
Dim j As Long
Dim vSheet As Worksheet
Dim dSheet As Worksheet
Dim oOption As MSForms.OptionButton
Set vSheet = ActiveWorkbook.Worksheets("Valuta")
Set dSheet = ActiveWorkbook.Worksheets("Data")
Application.ScreenUpdating = False
For Each oOption In FrmCur.Frame1
With oOption
If .Value = True Then
For x = 2 To 6
If Opt1.Caption = vSheet.Cells(x, 1).Value Then
With vSheet
For i = 6 To dSheet.Cells(1, 5).End(xlToRight).Column
If Not Right(.Cells(1, i).Value, 3) = "pct" Then
vSheet.Activate
vSheet.Cells(x, 2).Copy
dSheet.Activate
dSheet.Range(Cells(2, i), Cells(2, i).End(xlDown)).PasteSpecial Paste:=xlValues, operation:=xlMultiply
End If
Next i
End With
End If
Next x
End If
End With
Next oOption
For Each oOption In FrmCur.Frame2
With oOption
If .Value = True Then
For x = 2 To 6
If Opt1.Caption = vSheet.Cells(x, 1).Value Then
With vSheet
For i = 6 To dSheet.Cells(1, 5).End(xlToRight).Column
If Not Right(.Cells(1, i).Value, 3) = "pct" Then
vSheet.Activate
vSheet.Cells(x, 2).Copy
dSheet.Activate
dSheet.Range(Cells(2, i), Cells(2, i).End(xlDown)).PasteSpecial Paste:=xlValues, operation:=xlDivide
End If
Next i
End With
End If
Next x
End If
End With
Next oOption
FrmCur.Hide
Application.ScreenUpdating = True
End Sub
However this line;
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 :afrog:
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;
Private Sub CommandButton1_Click()
Dim x As Long
Dim i As Long
Dim j As Long
Dim vSheet As Worksheet
Dim dSheet As Worksheet
Dim oOption As MSForms.OptionButton
Set vSheet = ActiveWorkbook.Worksheets("Valuta")
Set dSheet = ActiveWorkbook.Worksheets("Data")
Application.ScreenUpdating = False
For Each oOption In FrmCur.Frame1
With oOption
If .Value = True Then
For x = 2 To 6
If Opt1.Caption = vSheet.Cells(x, 1).Value Then
With vSheet
For i = 6 To dSheet.Cells(1, 5).End(xlToRight).Column
If Not Right(.Cells(1, i).Value, 3) = "pct" Then
vSheet.Activate
vSheet.Cells(x, 2).Copy
dSheet.Activate
dSheet.Range(Cells(2, i), Cells(2, i).End(xlDown)).PasteSpecial Paste:=xlValues, operation:=xlMultiply
End If
Next i
End With
End If
Next x
End If
End With
Next oOption
For Each oOption In FrmCur.Frame2
With oOption
If .Value = True Then
For x = 2 To 6
If Opt1.Caption = vSheet.Cells(x, 1).Value Then
With vSheet
For i = 6 To dSheet.Cells(1, 5).End(xlToRight).Column
If Not Right(.Cells(1, i).Value, 3) = "pct" Then
vSheet.Activate
vSheet.Cells(x, 2).Copy
dSheet.Activate
dSheet.Range(Cells(2, i), Cells(2, i).End(xlDown)).PasteSpecial Paste:=xlValues, operation:=xlDivide
End If
Next i
End With
End If
Next x
End If
End With
Next oOption
FrmCur.Hide
Application.ScreenUpdating = True
End Sub
However this line;
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 :afrog: