Results 1 to 19 of 19

Stupid Input Box Error 2015

Threaded View

  1. #13
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Stupid Input Box Error 2015

    Not sure if it's what you want but this code will go down column A applying the appropriate
    text to columns where required.


    
    Sub Translate()
    Dim rng As Range
    Dim prelimorfinal As String
    Dim I As Long
    Dim arrShtNames
    
        'checks to see if the workbook has the appropriate amount of sheets
        If Sheets.Count <> 6 Then
            MsgBox "This code is meant for a workbook with 6 sheets."
        End If
    
        'let's get the worksheet names -- because I don't know the object variable for the below section to work properly.
        ReDim arrShtNames(1 To Sheets.Count)
        For I = 1 To Sheets.Count
            arrShtNames(I) = I & " - " & Sheets(I).Name
        Next I
    
    
        'we gonna ask to see which sheet needs to be translated, users should only pick one of the ones that says original.
        prelimorfinal = InputBox _
                        (Prompt:="Which sheet would you like to process? (Pick one of the 'Translated' sheets)" & vbNewLine & _
                                 Join(arrShtNames, vbNewLine) & _
                                 vbNewLine & _
                                 "Please insert a line number that corresponds with a worksheet.", Title:="Which sheet?")
    
    
        Application.DisplayAlerts = True
        'now we have selected which sheet we will translate
    
        'switching to the sheet we selected for translation
    
        For I = 1 To Worksheets(Val(prelimorfinal)).Range("A" & Rows.Count).End(xlUp)
    
            Set rng = ActiveWorkbook.Worksheets(Val(prelimorfinal)).Range("A" & I)
    
            Select Case Len(rng.Value)
    
                Case 1360
                    rng.TextToColumns Destination:=rng.Offset(3), DataType:=xlFixedWidth, _
                                      FieldInfo:=Array(Array(0, 1), Array(8, 1), Array(38, 1), Array(68, 1), Array(76, 1), _
                                                       Array(136, 1), Array(137, 1), Array(145, 1), Array(153, 1), Array(193, 1), Array(204, 1), _
                                                       Array(281, 1), Array(321, 1), Array(361, 1), Array(363, 1), Array(372, 1), Array(382, 1), _
                                                       Array(390, 1), Array(397, 1), Array(403, 1), Array(409, 1), Array(415, 1), Array(423, 1), _
                                                       Array(463, 1), Array(503, 1), Array(543, 1), Array(583, 1), Array(585, 1), Array(594, 1), _
                                                       Array(604, 1), Array(612, 1), Array(652, 1), Array(692, 1), Array(732, 1), Array(772, 1), _
                                                       Array(774, 1), Array(783, 1), Array(793, 1), Array(801, 1), Array(841, 1), Array(881, 1), _
                                                       Array(921, 1), Array(961, 1), Array(963, 1), Array(972, 1), Array(982, 1), Array(990, 1), _
                                                       Array(1030, 1), Array(1070, 1), Array(1110, 1), Array(1150, 1), Array(1152, 1), Array(1161, 1), _
                                                       Array(1171, 1), Array(1179, 1), Array(1219, 1), Array(1259, 1), Array(1299, 1), Array(1339, 1), _
                                                       Array(1341, 1), Array(1350, 1), Array(1360, 1))
                Case 38
                    rng.TextToColumns Destination:=rng.Offset(3), DataType:=xlFixedWidth, _
                                      FieldInfo:=Array(Array(0, 1), Array(6, 1), Array(7, 1), Array(15, 1), Array(23, 1), _
                                                       Array(26, 1), Array(29, 1), Array(32, 1), Array(35, 1), Array(38, 1))
                Case 263
                    rng.TextToColumns Destination:=rng.Offset(3), DataType:=xlFixedWidth, _
                                      FieldInfo:=Array(Array(0, 1), Array(1, 1), Array(9, 1), Array(17, 1), Array(18, 1), _
                                                       Array(26, 1), Array(34, 1), Array(35, 1), Array(43, 1), Array(51, 1), Array(59, 1), _
                                                       Array(60, 1), Array(61, 1), Array(62, 1), Array(64, 1), Array(72, 1), Array(80, 1), _
                                                       Array(88, 1), Array(96, 1), Array(104, 1), Array(112, 1), Array(152, 1), Array(192, 1), _
                                                       Array(232, 1), Array(234, 1), Array(243, 1), Array(253, 1), Array(263, 1))
                Case 43
                    rng.TextToColumns Destination:=rng.Offset(3), DataType:=xlFixedWidth, _
                                      FieldInfo:=Array(Array(0, 1), Array(1, 1), Array(9, 1), Array(17, 1), Array(25, 1), _
                                                       Array(33, 1), Array(41, 1), Array(42, 1), Array(43, 1))
    
                Case 19
                    rng.TextToColumns Destination:=rng.Offset(3), DataType:=xlFixedWidth, _
                                      FieldInfo:=Array(Array(0, 1), Array(1, 1), Array(9, 1), Array(11, 1), Array(19, 1))
            End Select
    
        Next I
    End Sub
    Last edited by Norie; 11-02-2012 at 03:44 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1