2

I am encountering a error Compile Error Array Expected. Am I using Ubound incorrectly? Should I declare myarray("Measurement", "", "Nominal", "Low", "High", "", "") With a Dim statement at the opening? If so then how to do I hande the rest of the statement?

   Private Sub Format_Parse_Replace()
    Dim i As Double
    Dim ws As Worksheet
    Set ws = ThisWorkbook.ActiveSheet
    Dim NomValue As String
    Dim myarray As String


    Dim rLastCell As Range
                Set rLastCell = ws.Cells.Find(What:="*", After:=ws.Cells(1, 1), LookIn:=xlFormulas, LookAt:= _
                xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=False)
    'MsgBox ("The last used column is: " & rLastCell.Column)
        Rows("4:6").EntireRow.Insert

        myarray = Array("Measurement", "", "Nominal", "Low", "High", "", "")
            Range("A2:A" & UBound(myarray) + 1) = _
            WorksheetFunction.Transpose(myarray)

    For i = rLastCell.Column To 2 Step -1
            'If Cells(1, i) = "Logbook" Then
                'Columns(i).Delete
            'End If
            'Set Col = ColLett(rLastCell.Column)
           NomValue = ws.Cells(3, i).Value
           Columns(i).Cells(4).NumberFormat = "@"
           Columns(i).Cells(5).NumberFormat = "@"
           Columns(i).Cells(6).NumberFormat = "@"
           Columns(i).Cells(4) = SplitString(NomValue, ",", 4)
           Columns(i).Cells(5) = SplitString(NomValue, ",", 5)
           Columns(i).Cells(6) = SplitString(NomValue, ",", 6)

    Next i
    Rows(3).Delete

    End Sub

Thank you

1 Answer 1

5

Excel Help: Array Function: Returns a Variant containing an array.

Dim myarray As String

Change to

Dim myarray As Variant
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.