Results 1 to 5 of 5

Thread: [RESOLVED] Excel Userform problems!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    96

    Resolved [RESOLVED] Excel Userform problems!

    Hi

    I've been trying to make a currency converter, but I can't get it to function correctly!?

    What I have is;
    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 sSheet As Worksheet
    8. Dim oOption As MSForms.Control
    9.  
    10. Set vSheet = ActiveWorkbook.Worksheets("Valuta")
    11. Set dSheet = ActiveWorkbook.Worksheets("Data")
    12. Set sSheet = ActiveWorkbook.Worksheets("Start")
    13.  
    14. Application.ScreenUpdating = False
    15.  
    16. For Each oOption In Me.Frame1.Controls
    17.   If TypeName(oOption) = Left(oOption.Caption, 3) = "opt" Then
    18.     With oOption
    19.         If .Value = True Then
    20.             For x = 2 To 6
    21.                 If .Caption = vSheet.Cells(x, 1).Value Then
    22.                 With vSheet
    23.                     For i = 6 To dSheet.Cells(1, 5).End(xlToRight).Column
    24.                     If Not Right(.Cells(1, i).Value, 3) = "pct" Then
    25.                                 vSheet.Activate
    26.                                 vSheet.Cells(x, 2).Copy
    27.                                 dSheet.Activate
    28.                                 dSheet.Range(Cells(2, i), Cells(2, i).End(xlDown)).PasteSpecial Paste:=xlValues, operation:=xlMultiply
    29.                                
    30.                     End If
    31.                     Next i
    32.                 End With
    33.                 End If
    34.             Next x
    35.         End If
    36.     End With
    37.   End If
    38. Next oOption
    39.  
    40. For Each oOption In Me.Frame2.Controls
    41.   If TypeName(oOption) = Left(oOption.Caption, 3) = "opt" Then
    42.     With oOption
    43.         If .Value = True Then
    44.             For x = 2 To 6
    45.                 If .Caption = vSheet.Cells(x, 1).Value Then
    46.                 With vSheet
    47.                     For i = 6 To dSheet.Cells(1, 5).End(xlToRight).Column
    48.                     If Not Right(.Cells(1, i).Value, 3) = "pct" Then
    49.                                 vSheet.Activate
    50.                                 vSheet.Cells(x, 2).Copy
    51.                                 dSheet.Activate
    52.                                 dSheet.Range(Cells(2, i), Cells(2, i).End(xlDown)).PasteSpecial Paste:=xlValues, operation:=xlDivide
    53.                                 sSheet.Cells(27, 7).Value = oOption.Caption
    54.                     End If
    55.                     Next i
    56.                 End With
    57.                 End If
    58.             Next x
    59.         End If
    60.     End With
    61.   End If
    62. Next oOption
    63.  
    64. FrmCur.Hide
    65.  
    66. Application.ScreenUpdating = True
    67.  
    68. End Sub

    I don't get any errors - but it doesn't do anything either! in other words - its useless!!

    Any ideas??

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Excel Userform problems!

    want to attach your workbook??

    pete

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    96

    Re: Excel Userform problems!

    I can't

    first off, the data is confidential - and secondly we don't have a zip program at work (for some odd reason), and it is some 7 MB total.

    I can try to describe it though
    I have 3 sheets;
    Start - The only visible sheet where the user is able to make some different selections - including the currency converter.

    Data - consist of all the data. columns 6 to 30 consist of numbers, some of which are percentages, these are marked with an pct as the last 3 letters and should not be converted (obviously)

    Valuta - 2 columns, one with the currency shortname (e.g. EUR) and the other with the exchange rate.

    hope this helps you...

  4. #4
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: Excel Userform problems!

    Your problem is in this line of code:
    VB Code:
    1. If TypeName(oOption) = Left(oOption.Caption, 3) = "opt" Then
    The TypeName function returns the class name of an object passed to it. So, if oOption is an OptionButton with "Dollars" in the caption, your if statement would look like this:
    VB Code:
    1. If "OptionButton" = "Dol" = "opt" Then
    This will always evaluate to false, even if you take out the Left call, because the TypeName of the option button will never equal "opt". You should probably use one of the following two tests instead (I'd use the first).
    VB Code:
    1. If TypeName(oOption) = "OptionButton" Then
    2. '...or
    3. If Left(oOption[COLOR=Red].Name[/COLOR], 3) = "opt" Then

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    96

    Re: Excel Userform problems!

    Hi

    Tried substitutting as you said, but still - nothing happens, no errors, nothing...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width