Excel VBA質問スレ Part13at TECH
Excel VBA質問スレ Part13 - 暇つぶし2ch572:デフォルトの名無しさん
09/11/08 09:57:39
>>569
import sys, os
import win32com.client

def main(from_s, from_e, to, rng):
if from_s[1] != from_e[1]:
print 'error'
return
if rng[0] > rng[1]:
print 'error'
return
pwd = os.path.abspath(os.curdir)
xls = win32com.client.Dispatch('Excel.Application')
try:
wb = xls.Workbooks.Open(os.path.join(pwd, 'test1.xls'))
sheet = wb.Sheets(1)
c = 0
for row in range(65535):
if row >= from_s[0] and row <= from_e[0]:
v = float(str(sheet.cells(row, from_s[1])))
if v >= rng[0] and v <= rng[1]:
sheet.cells(to[0] + c, to[1]).value = v
c += 1
wb.SaveAs(os.path.join(pwd, 'testout.xls'))
wb.Close()
except:
print sys.exc_info()
finally:
xls.Quit()

if __name__ == '__main__':
main((10, 2), (20, 2), (3, 5), (99.0, 1000.0)) # B10-B20 -> E3-


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch