Demo entry 2329807

VBA Test

   

Submitted by L33tCh on Jul 24, 2015 at 11:11
Language: VB.net. Code size: 857 Bytes.

Sub PasteTextTheHardway(Data As String)
  
    Dim BaseRow, BaseCol, ARow, ACOl As Integer
    
    BaseCol = ActiveCell.Column
    BaseRow = ActiveCell.row
    
    ARow = BaseRow
    ACOl = BaseCol
    
    Dim Text2Paste As String
    For i = 1 To Len(Data)
        If Mid(Data, i, 1) = Chr(9) Then
            Cells(ARow, ACOl) = Text2Paste
            Text2Paste = ""
       '     Cells(ARow, ACOl) = vbTab
            ACOl = ACOl + 1
        ElseIf Mid(Data, i, 1) = Chr(10) Then
           If ACOl = BaseCol Then
               ' empty row
            Else
                Cells(ARow, ACOl) = Text2Paste
                Text2Paste = ""
                ACOl = BaseCol
            End If
            ARow = ARow + 1
        Else
           Text2Paste = Text2Paste & Mid(Data, i, 1)
        End If
    
    Next
 End Sub

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).