-1

I have two text boxes on a form. One has string or the other one has values that are separated by vbnewline. Once it reaches the string "Total" in the text box, it should insert the string after two columns. If I am inserting in column A and reached the cell that equals = "Total" it should start inserting the strings in column C and the values in column D and so forth. Right now the code below inserts everything in two columns only (A & B) without going to the next columns. How do I start inserting the the strings and values in the next columns like (C & D), (E, & F) and so on when cell value is equal to "Total"?

Dim RowNum As Integer = 2
Dim ColNum As Integer = 1



    xlWorkSheet.Cells(1, 1).value = "Word"
    xlWorkSheet.Cells(1, 2).value = "Value"
    For Each cellA As String In txtWord.Text.Split(vbLf)
        xlWorkSheet.Cells(RowNum, ColNum).value = cellA
        RowNum += 1
        If xlWorkSheet.Cells(RowNum, ColNum).value = "Total" Then
            ColNum += 2
        End If
    Next
    RowNum = 2
    For Each cellB As String In txtValue.Text.Split(vbLf)

        xlWorkSheet.Cells(RowNum, 2).value = cellB
        RowNum += 1
        ColNum += 2
    Next
4

1 回答 1

1

这与您之前提出的问题相同。请参阅:在 vb.net 中的 Excel 工作表单元格中显示文本框结果

你可以在那里查看我修改后的答案。

于 2013-07-10T01:46:22.813 回答