Vba行数与第一个字母

时间:2018-06-08 08:31:06

标签: excel-vba counter vba excel

我想创建一个文本文件行计数器,但是如果我将所有列中的文本合并到每一行中的一个单元格中,则单元格中的更多thousends char会出错。我尝试拆分这个合并的字符串,只将第一个字符串放入每行的第一个单元格中,但它不起作用。我该如何修理它?或者我怎么才算第一列?

Sub counter()

    Dim GoToNum As Integer
    Dim Start As Integer
    GoToNum = 2
    Start = 3

    Do Until IsEmpty(Cells(Start, 1))
        GoToNum = GoToNum + 1
        Start = Start + 1
    Loop

    Dim SubCounter As Integer
    Dim curLine As String

    For i = 3 To GoToNum

            ConOrg = Cells(1, 4).Value & "\" & Cells(i, 1).Value

            'If Cells(i, 2).Value <= Cells(2, 5).Value Then

                Open ConOrg For Input As #1

                Do Until EOF(1)
                    SubCounter = SubCounter + 1
                    Line Input #1, Left(curLine, 1)
                    'ThisWorkbook.Sheets(1).Cells(SubCounter, 3).Value = curLine
                Loop

                Cells(i, 3).Value = SubCounter
                SubCounter = 0

                Close #1

            'End If

    Next i

End Sub

0 个答案:

没有答案