In Excel,
<tbody>
</tbody>
And the OUTPUT should be in NOTEPAD,
AN201@#BOS@#3061234@#035Yes@#102Yes@#10070@#097Yes@#Sometext shouldcome after a longspace thankyou
AN201@#BOS@#3061234@#035Yes@#102Yes@#10070@#097Yes@#This is second scenario thankyou
And the script which I tried is,
Sub Characterpostion()
Dim FilePath As String
Dim CellData As String
Dim LastCol As Long
Dim LastRow As Long
Dim str As String
Dim cellvalue As String
LastCol = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Column
LastRow = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row
FilePath = FreeFile
CellData = ""
Open "C:\Users\Antony\Music\Excel Macros\Text2.txt" For Output As #2
For i = 1 To LastRow
For j = 1 To LastCol
Select Case j
Case 1
n = 5 - Len(Trim(ActiveCell(i, j).Value))
Case 2
n = 3 - Len(Trim(ActiveCell(i, j).Value))
Case 3
n = 8 - Len(Trim(ActiveCell(i, j).Value))
Case 4
n = 7 - Len(Trim(ActiveCell(i, j).Value))
Case 5
n = 7 - Len(Trim(ActiveCell(i, j).Value))
Case 6
n = 6 - Len(Trim(ActiveCell(i, j).Value))
Case 7
n = 7 - Len(Trim(ActiveCell(i, j).Value))
End Select
CellData = CellData & Space & Trim(ActiveCell(i, j).Value) & "@#"
If CellData Like "*=*" Then
Dim WrdArray() As String
WrdArray() = Split(CellData, "=")
str = WrdArray(0) + WrdArray(1)
Print #2 , str
Else
End If
Next j
Print #2 , CellData
CellData = ""
Next i
Close #2
End Sub
But CellData stores all the case at a time... I am not able to null the CellData to restore the new value.
Appreciate your immediate response!! thanks
AN201 | BOS | 306=1234 | 035=Yes | 102=Yes | 100=70 | 097=Yes | Sometext shouldcome after a longspace thankyou |
AN201 | BOS | 306=1235 | 035=No | 102=No | 100=71 | 097=No | This is second scenario thankyou |
<tbody>
</tbody>
And the OUTPUT should be in NOTEPAD,
AN201@#BOS@#3061234@#035Yes@#102Yes@#10070@#097Yes@#Sometext shouldcome after a longspace thankyou
AN201@#BOS@#3061234@#035Yes@#102Yes@#10070@#097Yes@#This is second scenario thankyou
And the script which I tried is,
Sub Characterpostion()
Dim FilePath As String
Dim CellData As String
Dim LastCol As Long
Dim LastRow As Long
Dim str As String
Dim cellvalue As String
LastCol = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Column
LastRow = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row
FilePath = FreeFile
CellData = ""
Open "C:\Users\Antony\Music\Excel Macros\Text2.txt" For Output As #2
For i = 1 To LastRow
For j = 1 To LastCol
Select Case j
Case 1
n = 5 - Len(Trim(ActiveCell(i, j).Value))
Case 2
n = 3 - Len(Trim(ActiveCell(i, j).Value))
Case 3
n = 8 - Len(Trim(ActiveCell(i, j).Value))
Case 4
n = 7 - Len(Trim(ActiveCell(i, j).Value))
Case 5
n = 7 - Len(Trim(ActiveCell(i, j).Value))
Case 6
n = 6 - Len(Trim(ActiveCell(i, j).Value))
Case 7
n = 7 - Len(Trim(ActiveCell(i, j).Value))
End Select
CellData = CellData & Space & Trim(ActiveCell(i, j).Value) & "@#"
If CellData Like "*=*" Then
Dim WrdArray() As String
WrdArray() = Split(CellData, "=")
str = WrdArray(0) + WrdArray(1)
Print #2 , str
Else
End If
Next j
Print #2 , CellData
CellData = ""
Next i
Close #2
End Sub
But CellData stores all the case at a time... I am not able to null the CellData to restore the new value.
Appreciate your immediate response!! thanks