Всем добрый день.
Сделал файл для расчета по нескольким таблицам, одна из формул следующего вида =DSUM('REVENUE by TRANS. CODE'!$A$1:$W$1135;"AMOUNT";$M$3:$O$8), друга совсем простая =SUM('MARKET STATISTIC by SEGMENT'!$AF:$AF), но в одном и другом случае происходит смещение вправо при использование файла. После чего именно я понять не могу, так как файлом пользуются другие сотрудники.
Подскажите, по какой причине может происходить смещение? Т.е. 'REVENUE by TRANS. CODE'!$
A$1:$
W$1135 становится например 'REVENUE by TRANS. CODE'!$
AM$1:$
BP$1135.
В файл используется макрос закгрузки данных txt файлов но соответствующие вкладки, имена фалов всегда одинаковые.
Сначала хотел сам прописать открытие txt файлов для этого задавал переменные, но потом записал рекордером.
Код |
---|
Option Explicit
Dim sStat As String
Dim sStaty As String
Dim sRev As String
Dim OdirS As String
Dim odirSY As String
Dim odirR As String
Sub Import()
sStat = "Stat"
sStaty = "Stat-1"
sRev = "Rev"
OdirS = "C:\Users\h7149-gl4\Desktop\DRR\sStat.txt"
odirSY = "C:\Users\h7149-gl4\Desktop\DRR\sStaty.txt"
odirR = "C:\Users\h7149-gl4\Desktop\DRR\sRev.txt"
Sheets("MARKET STATISTIC by SEGMENT").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;U:\Forum\Daily Reports\DRR report\stat.txt", Destination:=Range("$A$1") _
)
.Name = "stat_3"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 866
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Sheets("MARKET STATISTIC by SEGMENT Y-1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;U:\Forum\Daily Reports\DRR report\stat-1.txt", Destination:=Range( _
"$A$1"))
.Name = "stat-1_2"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 866
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Sheets("REVENUE by TRANS. CODE").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;U:\Forum\Daily Reports\DRR report\Rev.txt", Destination:=Range("$A$1"))
.Name = "Rev_2"
.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 = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1, 1)
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
End With
Sheets("MAIN").Select
End Sub |