アプリ版:「スタンプのみでお礼する」機能のリリースについて

同じような質問は過去いくつかございますが、下記の条件を満たすことができず、
大変苦戦しております。

<条件>
1.フォルダ内すべてのエクセルで作成されたブックを、ブック名「全部」のsheet1に結合する。
2.結合するブックにはシートが複数あり、すべてのシートを結合するわけではなく、
 シート名「社員」の、指定した範囲内「a10:t100」を結合する。
3.ブック名「全部」のsheet1のa列には結合元のブック名を表示する。

ご教授いただければ幸いでございます。
どうかよろしくお願いいたします。

A 回答 (1件)

ブック「全部」に次のマクロを登録する


ブック「全部」を指定のファイルが入れてあるフォルダに保存する
マクロを実行する。

sub macro1()
 dim myPath as string
 dim myFile as string
 dim target as range
 on error resume next

 mypath = thisworkbook.path & "\"
 application.calculation = xlcalculationmanual
 application.screenupdating = false


 myfile = dir(mypath & "*.xls*")
 do until myfile = ""
  if myfile <> thisworkbook.name then
   set target = thisworkbook.worksheets("Sheet1").cells.specialcells(xlcelltypelastcell).offset(1).end(xltoleft)
   target = myfile
   with workbooks.open(filename:=mypath & myfile)
    .worksheets("社員").range("A10:T100").copy destination:=target.offset(0, 1)
    .close savechanges:=false
   end with
  end if
  myfile = dir()
 loop
 application.screenupdating = true
 application.calculation = xlcalculationautomatic
end sub


たぶん,ご相談で情報提供できていない箇所とかもあると思いますので,ご自分で適切に修正した上でご利用ください。
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!