Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am faced with this problem: "Identifier too long". What can I do to fix this? I tried using a break "_" . But there will another error: Missing end bracket. Thanks guys.

 Sub Netting()

     Dim Found As Range
     Dim LR As Long
     Dim ws As Worksheet
     Dim cell As Range
     Dim a As Variant, v As Variant, num

     Set ws = Sheets("PAYABLES - OUTFLOWS")

     Set Found = ws.Rows(1).Find(What:="Invoice Amount", _
                                LookIn:=xlValues, lookat:=xlWhole)
     If Found Is Nothing Then Exit Sub

     a = [{"991",1042;"916", 1042;"954",261;"975",3004;"938",726;"901",762;"482",728; _
            "482",728;"934",723;"200",724;"201",724;"952",724;"992",3030;"980",3207;"116",626;"939",722;"390",517;"484",548;"339",59;"141",717;"935",59;"994",3370;"140",8408;"950",775;"370", 734 }] 'create 2-d lookup array

     LR = ws.Cells(ws.Rows.Count, Found.Column).End(xlUp).Row
     Found.Offset(0, 1).EntireColumn.Insert
     ws.Cells(1, Found.Column + 1).Value = "Netting"

     For Each cell In ws.Range(ws.Range("C2"), ws.Cells(LR, 3))
        num = CStr(Mid(cell.Value, 3, 3))
        v = Application.VLookup(num, a, 2, False)
        cell.EntireRow.Cells(Found.Column + 1).Value = IIf(IsError(v), "", v)
     Next cell

End Sub
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
236 views
Welcome To Ask or Share your Answers For Others

1 Answer

There is a limit on the number of characters per line. You can accomplish this using a much simpler way. Add your data to a spreadsheet ("Sheet1" for example) and in column A and column B.

Sub Assign2DVector()
    Dim ws As Worksheet
    Set ws = ThisWorkbook.Worksheets("Sheet1")
    Dim a As Variant
    a = ws.Range("A1:B20").Value ' set to whatever your actual range is
End Sub

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...