Please suggest a correct method to over come this, I need Output like this 10E001 I dont want 100
another solution:
- highlight column in excel
- click data-> text to column
.3 select TEXT and click FINISH
- now when you write to this cell, it will show 10E001
How to Apply text format using bot
I am going convert this excel data into text format, that time i would get appostopy, instead of appostopy I need another method.
here
- create txt file VBAFunction.txt
paste this inside
Function ChangeFormatToText(sheetName As String)
Dim ws As Worksheet
Set ws = ActiveWorkbook.Sheets(sheetName)
ws.Activate
Dim rLastCell As Range
Set rLastCell = ws.Cells.Find(What:="*", After:=ws.Cells(1, 1), LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=False)
Dim lastColumnNumber as Integer
if rLastCell is nothing then
lastColumnNumber = 100
else
lastColumnNumber = rLastCell.Column
end if
Rows(1).Insert
Range(Cells(1, 1), Cells(1, lastColumnNumber)).Value = "test"
For i = 1 To lastColumnNumber
Columns(i).Select
Selection.TextToColumns Destination:=Cells(1, i), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 2), TrailingMinusNumbers:=True
Selection.NumberFormat = "@"
Next i
Rows(1).Delete
ActiveWorkbook.Save
End Function
Then in excel application scope, call vba function using invoke vba, in EntryMethodParamters pass in your sheet name e.g. {“Sheet1”}
now if you write cell it will be text format
is this Code Convert the whole Sheet1 of the excel or it will convert a particular Column into text format
whole sheet (up to last column), or do you only want 1 column?
Meanwhile running this i am getting this
Provide a Code for Single COlumn
this
then when calling you need to add sheet name parameter and column letter
e.g. {“Sheet1”,“C”} for column C and sheet1
Function ChangeFormatToText(sheetName As String, colLetter As String)
Dim ws As Worksheet
Set ws = ActiveWorkbook.Sheets(sheetName)
ws.Activate
Rows(1).Insert
Range(colLetter & "1").Value = "test"
Dim columnNumber As Integer
columnNumber = Range(colLetter & "1").Column
Columns(columnNumber).Select
Selection.TextToColumns Destination:=Cells(1, columnNumber), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
:=Array(1, 2), TrailingMinusNumbers:=True
Selection.NumberFormat = "@"
Rows(1).Delete
ActiveWorkbook.Save
End Function
if i want to Change the Column name from C to A means, If it is enough to change Column name in Parameter
yes you can change however you like .
Thank you Jack.chan Its Working Fine
How to Convert into text format in .csv file
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.