|
сумма ячеек из разных файлов
|
|||
---|---|---|---|
#18+
Добрый день Уверен такая задача уже рассматривалась! Excel Необходимо сложить одни и те же ячейки из разных файлов. то есть ЯчейкаИтоговойТаблицы(С11) = НужнаяЯчейкаИзФайла№1(С11) +НужнаяЯчейкаИзФайла№2(С11) + и т.д. ЯчейкаИтоговойТаблицы(С12) = НужнаяЯчейкаИзФайла№1(С12) +НужнаяЯчейкаИзФайла№2(С12) + и т.д. в моём случае складываются ячейки с одими и теми же номерами(в примере это С11 и С12), так как файлы одинаковой структуры Не програмер далеко, поэтому мне бы готовый макрос с комментариями где указывать имена файлов и номера ячеек которые нужно складывать. Извиняюсь за наглость, но может кто уже такое писал)). ... |
|||
:
Нравится:
Не нравится:
|
|||
19.01.2007, 14:21 |
|
сумма ячеек из разных файлов
|
|||
---|---|---|---|
#18+
Вообще по-моему в этом случае оптимальнее использовать формулы (вручную или через VBA), но если очень хочется, то см. цитату ниже. KL [MVP - Microsoft Excel] ------------- http://www.j-walk.com/ss/excel/eee/eee009.txt ------------ Created by Bob Umlas and adaptation to a Function procedure by John Walkenbach This procedure allows for the access of information in a closed workbook with VBA. From Bob: Here's a routine you can incorporate into your programs if you ever have a need to retrieve data from a file without opening it. In the needed case, I had to read any number of files (depending on user's selection from a listbox) and determine whether range W11:W36 on sheet "General" totalled zeroand do one thing if ANY file met that condition or another thing if not. At first, I thought I'd need to open each file, take the sum, then close it again. Not true. By building a string which you can pass into the ExecuteExcel4Macro, you can access this info directly, without opening the file, making it very fast: Sub GetDataFromClosedFile() filepath = "G:\fsoft\sos\data\ley" FileName = "1cA10.sos" '<==this could change in a loop sheetname = "General" Strg = "sum('" & filepath & "\[" & FileName & "]" & sheetname & "'!r11c23:r36c23)" MsgBox ExecuteExcel4Macro(Strg) End Sub 'In reality, it looked like this: Sub GetDataFromClosedFile() filepath = "G:\fsoft\sos\data\ley" sheetname = "General" For Each Fl In DialogSheets("DlgMulti").ListBoxes("MainList").List Strg = "sum('" & filepath & "\[" & Fl & "]" & sheetname & "'!r11c23:r36c23)" Ans = ExecuteExcel4Macro(Strg) If Ans > 0 Then Exit Sub Next 'none > 0 '...rest of code goes here End Sub ... |
|||
:
Нравится:
Не нравится:
|
|||
19.01.2007, 14:42 |
|
сумма ячеек из разных файлов
|
|||
---|---|---|---|
#18+
KL (XL)Вообще по-моему в этом случае оптимальнее использовать формулы (вручную или через VBA), но если очень хочется, то см. цитату ниже. с удовольствием выслушаю более оптимальное решение проблемы ... |
|||
:
Нравится:
Не нравится:
|
|||
19.01.2007, 14:48 |
|
сумма ячеек из разных файлов
|
|||
---|---|---|---|
#18+
ставил это: 'In reality, it looked like this: Sub GetDataFromClosedFile() filepath = "D:\" sheetname = "1l" For Each Fl In DialogSheets("DlgMulti").ListBoxes("MainList").List Strg = "sum('" & filepath & "\[" & Fl & "]" & sheetname & "'!r11c23:r36c23)" Ans = ExecuteExcel4Macro(Strg) If Ans > 0 Then Exit Sub Next 'none > 0 '...rest of code goes here End Sub выдало: Run time error '9' Subscript out of range извиняюсь за некомпетентность ... |
|||
:
Нравится:
Не нравится:
|
|||
19.01.2007, 14:54 |
|
сумма ячеек из разных файлов
|
|||
---|---|---|---|
#18+
извиняюсь за некомпетентность[/quot] нашел ответ здесь: http://www.excel-vba.ru/chto-umeet-excel/kak-bystro-umnozhitrazdelitslozhitvychest-iz-mnozhestva-yacheek-odno-i-to-zhe-chislo/ если конечно все еще актуально ;-) ... |
|||
:
Нравится:
Не нравится:
|
|||
04.12.2012, 12:26 |
|
|
start [/forum/topic.php?fid=61&fpage=88&tid=2175177]: |
0ms |
get settings: |
11ms |
get forum list: |
13ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
29ms |
get topic data: |
13ms |
get forum data: |
3ms |
get page messages: |
47ms |
get tp. blocked users: |
2ms |
others: | 13ms |
total: | 139ms |
0 / 0 |