* .CSV 파일에서 데이터를 가져올 때 "날짜 형식"으로 된 날짜를 가져 오지 않기 때문에 VBA를 사용하여 셀 내용 검색을 사용하지 않도록 설정하는 방법을 알아야합니다. 만약 내가 그것을 가져올 때 텍스트입니다 지정합니다. Dates를 String으로하고 싶습니다. 가져온 후에 형식을 변경하려고하면 날짜가있는 문자열 대신 숫자가 표시됩니다.vba를 사용하여 셀 내용 감지 사용 안 함
Cells.Select
Selection.NumberFormat = "@"
'importo los datos
With ActiveSheet.QueryTables.Add(Connection:=datosConexion, Destination:=Range("$A$1"))
.name = archivo
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 65001
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = False
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, _
1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
.TextFileDecimalSeparator = "."
.TextFileThousandsSeparator = ","
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
방법 각 문자열의 시작 부분에 아포스트로피를 추가하는 것에 대해? '' ' "& string' – kaybee99
그 코드로 어떻게 할 수 있습니까? 왜냐하면 나는 행별로 * .csv 파일을 읽지 않기 때문이다. 방금 매크로를 기록하고 필요한 코드를 변경하여 코드를 사용했습니다. @ kaybee99 ?? – Carol