Excel VBA質問箱 IV

当質問箱は、有志のボランティア精神のおかげで成り立っています。
問題が解決したら、必ずお礼をしましょうね。
本サイトの基本方針をまとめました。こちら をご一読ください。

投稿種別の選択が必要です。ご注意ください。
迷惑投稿防止のため、URLの入力を制限しています。ご了承ください。


359 / 3841 ページ ←次へ | 前へ→

【75235】www.hellokanpo.com
質問  www.hellokanpo.com E-MAIL  - 14/1/17(金) 11:20 -

引用なし
パスワード
   黒倍王:www.hellokanpo.com/view/heibeiwang.html
三鞭粒:www.hellokanpo.com/view/wei.html
セフラジン:www.hellokanpo.com/view/kangshengwuzhi.html
情愛芳香劑:www.hellokanpo.com/rush/
蔵秘雄精:www.hellokanpo.com/view/zangmitiongjing.html
夜狼神:www.hellokanpo.com/view/yelangshen.html
中華牛鞭:www.hellokanpo.com/view/zhonghua.html
ビグレックス:www.hellokanpo.com/view/oil.html
アフリカ超人:www.hellokanpo.com/view/chaoren.html
インモラル:immoral.hellokanpo.com
淫インモラル:immoral.hellokanpo.com
悦可亭:www.hellokanpo.com/view/yueke.html
止血薬 カルバゾクロム錠:www.hellokanpo.com/view/zhixueyao.html
女性用バイアグラ:www.hellokanpo.com/view/nvweige.html
安宮牛黄丸:www.hellokanpo.com/view/tongrenangong.html
碧生源減肥:www.hellokanpo.com/view/bishengyuan.html
D10催情剤:www.hellokanpo.com/view/D10-meiyao.html
徳国黒金:www.hellokanpo.com/view/deguoheijin.html
Xing霸:www.hellokanpo.com/view/xingba2000.html
性霸2000:www.hellokanpo.com/view/xingba2000.html
壮天根:www.hellokanpo.com/view/ZTG.html
九鞭粒:www.hellokanpo.com/view/jiubianli.html
蔵秘男宝:www.hellokanpo.com/view/zangmi.html
藏秘男宝:www.hellokanpo.com/view/zangmi.html
奇果:www.hellokanpo.com/view/qiguo.html
LIDO SPRAY:www.hellokanpo.com/view/Lidosprayer.html
リドスプレー:www.hellokanpo.com/view/Lidosprayer.html
妖姫:youhi.hellokanpo.com
インモラル:immoral.hellokanpo.com
淫インモラル:immoral.hellokanpo.com
夜夜堅:www.hellokanpo.com/view/yeyejian1200.html
好漢哥:www.hellokanpo.com/view/haohange.html
VVK:www.hellokanpo.com/view/VVK-Wenickman.html
Wenickman:www.hellokanpo.com/view/VVK-Wenickman.html
金博郎:www.hellokanpo.com/view/JinBoLang.html
力多精:www.hellokanpo.com/view/lid-jing.html

立挺90度:www.hellokanpo.com/view/liting90.html
男根増長素:www.hellokanpo.com/view/nangen.html
消渇丸:www.hellokanpo.com/view/xiaokewan.html
消渇丸 輸入:www.hellokanpo.com/view/xiaokewan.html
新一粒神:www.hellokanpo.com/view/xinyilishen.html
壮三天:www.hellokanpo.com/view/zhuangsantian.html
魔根:www.hellokanpo.com/view/muogen.html
金動力:www.hellokanpo.com/view/jindongli.html
・・・ス:www.hellokanpo.com/view/heise-fengbao.html
男露888:www.hellokanpo.com/view/nanlu888.html
蔵八宝:www.hellokanpo.com/view/zhangbabao.html
西班牙蒼蝿水:www.hellokanpo.com/view/xibanyamoli.html
鹿茸腎宝:www.hellokanpo.com/view/lurong.html
MaxMan:www.hellokanpo.com/view/MaxMan.html
勃動力三體牛鞭:www.hellokanpo.com/view/santiniubian.html
五便宝:www.hellokanpo.com/view/wodibo-capsules.html
男宝:www.hellokanpo.com/view/nanbao.html
VigRx:www.hellokanpo.com/view/vigrx.html
vigrxプラス:www.hellokanpo.com/view/vigrx.html
巨人倍増:www.hellokanpo.com/view/jurenbeiceng.html
巨人倍増 通販:www.hellokanpo.com/view/jurenbeiceng.html
三體牛鞭:www.hellokanpo.com/view/santiniubian.html
三体牛鞭:www.hellokanpo.com/view/santiniubian.html
威哥王:www.hellokanpo.com/view/weigewang.html
狼1号:www.hellokanpo.com/view/langyihao.html
狼一号:www.hellokanpo.com/view/langyihao.html
三便宝:www.hellokanpo.com/view/satibo-capsules.html
蟻力神:www.hellokanpo.com/view/yilishen.html
淫インモラル:immoral.hellokanpo.com
インモラル:immoral.hellokanpo.com
金威龍:www.hellokanpo.com/view/jinweilong.html
房事神油:www.hellokanpo.com/view/fangshi.html
性福三宝:www.hellokanpo.com/view/xingfusanbao.html
五夜神:www.hellokanpo.com/view/tbwy.html
野生虫草王:www.hellokanpo.com/view/yesheng.html
東方神龍生精:www.hellokanpo.com/view/dongfuangshenlong.html
壮陽一号:www.hellokanpo.com/view/zhuangyangyihao.html
達克寧:www.hellokanpo.com/view/dakening.html
RUSH BLUE:www.hellokanpo.com/view/rush550.html
ULTRA RUSH:www.hellokanpo.com/view/rush549.html
ラッシュ芳香劑:www.hellokanpo.com/view/rush559.html

妖姫:youhi.hellokanpo.com
インモラル:immoral.hellokanpo.com
淫インモラル:immoral.hellokanpo.com
情愛芳香劑:www.hellokanpo.com/rush/
妻之友:www.hellokanpo.com/view/qizhi.html
D10媚薬:www.hellokanpo.com/view/D10-meiyao.html
D10催情剤:www.hellokanpo.com/view/D10-meiyao.html
絶對高潮:www.hellokanpo.com/view/juedui.html
絶對高潮カプセル:www.hellokanpo.com/view/juedui.html
D10:www.hellokanpo.com/view/D10-meiyao.html
d9催情:www.hellokanpo.com/view/D9-INVERMA.html
D8 催情剤:www.hellokanpo.com/view/SpanishFliegeD8.html
FLY D5:www.hellokanpo.com/view/fly-d5.html
D5原液:www.hellokanpo.com/view/FLYD5yuan.html
蒼蝿水:www.hellokanpo.com/view/FLY-D5.html
花之欲:www.hellokanpo.com/view/huazhiyu.html
美人豹:www.hellokanpo.com/view/meirenbao.html
福源春:www.hellokanpo.com/view/fuyuanchun.html
催情丹:www.hellokanpo.com/view/cuiqingdan.html
魔鬼天使性欲粉:www.hellokanpo.com/view/mogui-tianshi.html
蟻王:www.hellokanpo.com/view/antking.html
アリ王:www.hellokanpo.com/view/antking.html
SEX DROPS:www.hellokanpo.com/view/sex-drops.html
VOV催情粉:www.hellokanpo.com/view/vovcuiqing.html
VOV催情液:www.hellokanpo.com/view/VOVcuiqingye.html
小情人:www.hellokanpo.com/view/sex-drops5.html
スペイン セックス ドロップ:www.hellokanpo.com/view/SpanishFliegeD8.html
片仔廣:www.hellokanpo.com/view/pientze-huang.html
へんしこう:www.hellokanpo.com/view/pientze-huang.html
同仁堂牛黄清心丸:www.hellokanpo.com/view/trtnh.html
牛黄清心丸:www.hellokanpo.com/view/trtnh.html

催情剤:www.hellokanpo.com/view/D10-meiyao.html
催情:www.hellokanpo.com/view/D10-meiyao.html
催情粉:www.hellokanpo.com/view/hongzhizhu1.html
催淫剤:www.hellokanpo.com/view/jueduigaochao.html
ペニス増大:www.hellokanpo.com/view/VVK-Wenickman.html
終極痩身:www.hellokanpo.com/view/zhongjishoushen.html
超級脂肪燃焼弾:www.hellokanpo.com/view/FATBURNING.html
スーパーファット:www.hellokanpo.com/view/FATBURNING.html
大印象ダイエット茶:www.hellokanpo.com/view/dayinxiang.html
御秀堂:www.hellokanpo.com/view/yuxiutang.html
RU486:www.hellokanpo.com/view/beijing-ru486.html
ru486 個人輸入:www.hellokanpo.com/view/beijing-ru486.html
淫インモラル:immoral.hellokanpo.com
インモラル:immoral.hellokanpo.com
媚薬 淫インモラル:immoral.hellokanpo.com
媚薬 インモラル:immoral.hellokanpo.com
淫インモラル 販売:immoral.hellokanpo.com
インモラル 販売:immoral.hellokanpo.com
媚薬 妖姫:youhi.hellokanpo.com
妖姫 効果:youhi.hellokanpo.com
妖姫 販売:youhi.hellokanpo.com
妖姫 通販:youhi.hellokanpo.com
妖姫:youhi.hellokanpo.com
・ツリー全体表示

【75234】www.hellokanpo.com
質問  www.hellokanpo.com E-MAIL  - 14/1/17(金) 11:18 -

引用なし
パスワード
   黒倍王:www.hellokanpo.com/view/heibeiwang.html
三鞭粒:www.hellokanpo.com/view/wei.html
セフラジン:www.hellokanpo.com/view/kangshengwuzhi.html
情愛芳香劑:www.hellokanpo.com/rush/
蔵秘雄精:www.hellokanpo.com/view/zangmitiongjing.html
夜狼神:www.hellokanpo.com/view/yelangshen.html
中華牛鞭:www.hellokanpo.com/view/zhonghua.html
ビグレックス:www.hellokanpo.com/view/oil.html
アフリカ超人:www.hellokanpo.com/view/chaoren.html
インモラル:immoral.hellokanpo.com
淫インモラル:immoral.hellokanpo.com
悦可亭:www.hellokanpo.com/view/yueke.html
止血薬 カルバゾクロム錠:www.hellokanpo.com/view/zhixueyao.html
女性用バイアグラ:www.hellokanpo.com/view/nvweige.html
安宮牛黄丸:www.hellokanpo.com/view/tongrenangong.html
碧生源減肥:www.hellokanpo.com/view/bishengyuan.html
D10催情剤:www.hellokanpo.com/view/D10-meiyao.html
徳国黒金:www.hellokanpo.com/view/deguoheijin.html
Xing霸:www.hellokanpo.com/view/xingba2000.html
性霸2000:www.hellokanpo.com/view/xingba2000.html
壮天根:www.hellokanpo.com/view/ZTG.html
九鞭粒:www.hellokanpo.com/view/jiubianli.html
蔵秘男宝:www.hellokanpo.com/view/zangmi.html
藏秘男宝:www.hellokanpo.com/view/zangmi.html
奇果:www.hellokanpo.com/view/qiguo.html
LIDO SPRAY:www.hellokanpo.com/view/Lidosprayer.html
リドスプレー:www.hellokanpo.com/view/Lidosprayer.html
妖姫:youhi.hellokanpo.com
インモラル:immoral.hellokanpo.com
淫インモラル:immoral.hellokanpo.com
夜夜堅:www.hellokanpo.com/view/yeyejian1200.html
好漢哥:www.hellokanpo.com/view/haohange.html
VVK:www.hellokanpo.com/view/VVK-Wenickman.html
Wenickman:www.hellokanpo.com/view/VVK-Wenickman.html
金博郎:www.hellokanpo.com/view/JinBoLang.html
力多精:www.hellokanpo.com/view/lid-jing.html

立挺90度:www.hellokanpo.com/view/liting90.html
男根増長素:www.hellokanpo.com/view/nangen.html
消渇丸:www.hellokanpo.com/view/xiaokewan.html
消渇丸 輸入:www.hellokanpo.com/view/xiaokewan.html
新一粒神:www.hellokanpo.com/view/xinyilishen.html
壮三天:www.hellokanpo.com/view/zhuangsantian.html
魔根:www.hellokanpo.com/view/muogen.html
金動力:www.hellokanpo.com/view/jindongli.html
・・・ス:www.hellokanpo.com/view/heise-fengbao.html
男露888:www.hellokanpo.com/view/nanlu888.html
蔵八宝:www.hellokanpo.com/view/zhangbabao.html
西班牙蒼蝿水:www.hellokanpo.com/view/xibanyamoli.html
鹿茸腎宝:www.hellokanpo.com/view/lurong.html
MaxMan:www.hellokanpo.com/view/MaxMan.html
勃動力三體牛鞭:www.hellokanpo.com/view/santiniubian.html
五便宝:www.hellokanpo.com/view/wodibo-capsules.html
男宝:www.hellokanpo.com/view/nanbao.html
巨人倍増:www.hellokanpo.com/view/jurenbeiceng.html
巨人倍増 通販:www.hellokanpo.com/view/jurenbeiceng.html
淫インモラル:immoral.hellokanpo.com
インモラル:immoral.hellokanpo.com
金威龍:www.hellokanpo.com/view/jinweilong.html
房事神油:www.hellokanpo.com/view/fangshi.html
性福三宝:www.hellokanpo.com/view/xingfusanbao.html
五夜神:www.hellokanpo.com/view/tbwy.html
野生虫草王:www.hellokanpo.com/view/yesheng.html
東方神龍生精:www.hellokanpo.com/view/dongfuangshenlong.html
壮陽一号:www.hellokanpo.com/view/zhuangyangyihao.html
達克寧:www.hellokanpo.com/view/dakening.html
RUSH BLUE:www.hellokanpo.com/view/rush550.html
ULTRA RUSH:www.hellokanpo.com/view/rush549.html
ラッシュ芳香劑:www.hellokanpo.com/view/rush559.html

妖姫:youhi.hellokanpo.com
インモラル:immoral.hellokanpo.com
淫インモラル:immoral.hellokanpo.com
情愛芳香劑:www.hellokanpo.com/rush/
妻之友:www.hellokanpo.com/view/qizhi.html
D10媚薬:www.hellokanpo.com/view/D10-meiyao.html
D10催情剤:www.hellokanpo.com/view/D10-meiyao.html
絶對高潮:www.hellokanpo.com/view/juedui.html
絶對高潮カプセル:www.hellokanpo.com/view/juedui.html
D10:www.hellokanpo.com/view/D10-meiyao.html
d9催情:www.hellokanpo.com/view/D9-INVERMA.html
D8 催情剤:www.hellokanpo.com/view/SpanishFliegeD8.html
FLY D5:www.hellokanpo.com/view/fly-d5.html
D5原液:www.hellokanpo.com/view/FLYD5yuan.html
蒼蝿水:www.hellokanpo.com/view/FLY-D5.html
花之欲:www.hellokanpo.com/view/huazhiyu.html
美人豹:www.hellokanpo.com/view/meirenbao.html
福源春:www.hellokanpo.com/view/fuyuanchun.html
催情丹:www.hellokanpo.com/view/cuiqingdan.html
魔鬼天使性欲粉:www.hellokanpo.com/view/mogui-tianshi.html
蟻王:www.hellokanpo.com/view/antking.html
アリ王:www.hellokanpo.com/view/antking.html
SEX DROPS:www.hellokanpo.com/view/sex-drops.html
VOV催情粉:www.hellokanpo.com/view/vovcuiqing.html
VOV催情液:www.hellokanpo.com/view/VOVcuiqingye.html
小情人:www.hellokanpo.com/view/sex-drops5.html
スペイン セックス ドロップ:www.hellokanpo.com/view/SpanishFliegeD8.html
片仔廣:www.hellokanpo.com/view/pientze-huang.html
へんしこう:www.hellokanpo.com/view/pientze-huang.html
同仁堂牛黄清心丸:www.hellokanpo.com/view/trtnh.html
牛黄清心丸:www.hellokanpo.com/view/trtnh.html
終極痩身:www.hellokanpo.com/view/zhongjishoushen.html
超級脂肪燃焼弾:www.hellokanpo.com/view/FATBURNING.html
スーパーファット:www.hellokanpo.com/view/FATBURNING.html
大印象ダイエット茶:www.hellokanpo.com/view/dayinxiang.html
御秀堂:www.hellokanpo.com/view/yuxiutang.html
RU486:www.hellokanpo.com/view/beijing-ru486.html
ru486 個人輸入:www.hellokanpo.com/view/beijing-ru486.html
淫インモラル:immoral.hellokanpo.com
インモラル:immoral.hellokanpo.com
媚薬 淫インモラル:immoral.hellokanpo.com
媚薬 インモラル:immoral.hellokanpo.com
淫インモラル 販売:immoral.hellokanpo.com
インモラル 販売:immoral.hellokanpo.com
媚薬 妖姫:youhi.hellokanpo.com
妖姫 効果:youhi.hellokanpo.com
妖姫 販売:youhi.hellokanpo.com
妖姫 通販:youhi.hellokanpo.com
妖姫:youhi.hellokanpo.com
淫インモラル:immoral.hellokanpo.com
インモラル:immoral.hellokanpo.com
999皮炎平軟膏:www.hellokanpo.com/view/999piyan.html
同仁烏鶏白鳳丸:www.hellokanpo.com/view/tongrenwuji.html
婦科千金片:www.hellokanpo.com/view/fukeqian.html
維尼好:www.hellokanpo.com/view/wnh.html
司米安:www.hellokanpo.com/view/simian.html
・ツリー全体表示

【75233】Re:リストと一致するデータを検索
お礼  zucchi  - 14/1/17(金) 9:32 -

引用なし
パスワード
   ありがとうございます!
まだちゃんと内容を確認できていませんが
なんかとても素晴らしい感じです!
本日はこの件に手をつけられない状況なので
土日の間にじっくりと拝見&トライしてみたいと思います。
まずはお礼まで。
・ツリー全体表示

【75232】Re:リストと一致するデータを検索
発言  kanabun  - 14/1/16(木) 17:25 -

引用なし
パスワード
   ▼zucchi さん:
>リスト1を検索してリスト2の中にあるデータと一致するものがあるかどうか
>を検索する

こんにちは〜
フィルタオプション(AdvancedFilter)を使ったらどうでしょう?
入荷リストのB列に対し、禁止リストのA列を抽出条件範囲として一致する行だけ
抽出するのです。
入荷リストのB列と禁止リストのA列の一行目は同一の見出しとしてください。

Sub test1()
  Dim ws1 As Worksheet '入荷リストのあるシート
  Dim r1 As Range 'ws1のB列
  Dim ws2 As Worksheet '出荷禁止リストのシート
  Dim r2 As Range 'ws2のA列
  
  Set ws1 = Workbooks("F_Data.xls").Worksheets("入荷リスト")'要変更
  Set ws2 = Workbooks("Book1").Worksheets("禁止リスト")   '要変更
  Set r1 = ws1.Range("A1").CurrentRegion.Columns(2)
  Set r2 = ws2.Range("A1").CurrentRegion.Columns(1)
  r1.AdvancedFilter xlFilterInPlace, CriteriaRange:=r2
  If r1.SpecialCells(xlVisible).Count > 1 Then
    MsgBox "この商品番号は出荷禁止です"
  Else
    ws1.ShowAllData
    MsgBox "すべて出荷できます"
  End If
End Sub
・ツリー全体表示

【75231】リストと一致するデータを検索
質問  zucchi  - 14/1/16(木) 13:41 -

引用なし
パスワード
   リスト1を検索してリスト2の中にあるデータと一致するものがあるかどうか
を検索する処理をしたいのですが
具体的には
入荷リストのB列に商品番号が載っています。データは200件ほど。
別ファイルで出荷禁止リストがあり、A列に商品番号が記載されています。(20件ほど)
入荷リストの中に出荷禁止のものがあれば、何らかの形で
それを知らせてくれるような物を作りたいのです。
検索値が複数ある場合の処理がわからずに困っております。
よろしくお願いします。
・ツリー全体表示

【75230】Excel2010→2013にアップ後、VBA動作違う...
質問  おもむろ  - 14/1/13(月) 18:22 -

引用なし
パスワード
   やりたいことは、Excelファイルをテンプレートとして印刷プレビューすることです。
ソースコードは下記示す。

'ファイル開く処理(略)

'ファイル開く後はExcel画面を隠れる
Application.Visible = False
Application.ScreenUpdating = False

'Excelシート編集処理(略)

'プレビュー前にはExcel画面を表示するように
Application.Visible = True

'プレビュー実施
Sheets(Array("Sheet1", "Sheet2", "Sheet3")).Select
  ActiveWindow.SelectedSheets.PrintPreview

問題点は、Excel2013環境で正常にプレビュー画面表示されるが、
前ページ、次ページを押すと反応無しになってしまいます。
同じ様なコードは2010で正しく動けている。
・ツリー全体表示

【75229】Re:助けてください。最終行に合計を求め...
発言  γ  - 14/1/9(木) 22:31 -

引用なし
パスワード
   For i = 4 To 7
  j = Application.Max(j, Cells(1048576, i).End(xlUp).Row + 1)
Next
ところで、このコードの意味は何だったのですか?
合計を取るわけでもないですしねえ。

普通は、
コードを書くほうが労力がかかるので、コードが正しく、
日本語の説明を漏らしてしまいました、ということが多いわけですが、
今回は、
間違って苦労してコードを書いてしまいました、
ということだったのでしょうか。
不思議です。
・ツリー全体表示

【75228】Re:助けてください。最終行に合計を求め...
回答  ウッシ  - 14/1/9(木) 14:11 -

引用なし
パスワード
   こんにちは


>Range("D1", Range("a" & Rows.Count).End(xlUp)).Resize(, 11).Borders.LineStyle = True

ですか?

これでは結局全てに罫線が引かれちゃわないですか?

  With sh.Range("A1").CurrentRegion
    .Resize(.Rows.Count - 1, 11).Borders.LineStyle = xlDouble
'    .Columns(4).Resize(.Rows.Count - 1, 11).Borders.LineStyle = xlDouble
  End With

D列以降ならコメントアウトした方のコードにしてみて下さい。
・ツリー全体表示

【75227】Re:助けてください。最終行に合計を求め...
お礼  きおら  - 14/1/9(木) 13:52 -

引用なし
パスワード
   ▼γ さん:
>totalRow = Application.Max(totalRow, Cells(1048576, i).End(xlUp).Row + 1)
>は
>totalRow = Application.Max(totalRow, Cells(Rows.Count, i).End(xlUp).Row + 1)
>としたほうがよい。見過ごしていました。

ありがとうございます。
この指定の仕方が前から分からなくって
勉強になりました。
ありがとうございました。
・ツリー全体表示

【75226】Re:助けてください。最終行に合計を求め...
お礼  きおら  - 14/1/9(木) 13:51 -

引用なし
パスワード
   ありがとうございます。
下記の様にご指導いただいた通り、使わせていただき
うまくいきました。
セットした合計行の上だけ、二重罫線にしたくて
色々やってみましたが、どんどん混乱したので
あきらめて。普通の罫線にしました(笑)
ありがとうございました。

Sub 1.申請()
Application.ScreenUpdating = False
  ActiveWorkbook.Save
  With Worksheets("DB")
    .Range("d1").AutoFilter _
      Field:=6, Criteria1:="1"
      .Range("D1").CurrentRegion.SpecialCells(xlCellTypeVisible).Copy _
      Worksheets("申請").Range("a1")
      .AutoFilterMode = False
  End With
  Worksheets("申請").Activate
    Dim sh As Worksheet
  Set sh = ThisWorkbook.Worksheets("申請")
  With sh.Range("A" & Rows.Count).End(xlUp).Offset(1)
    .Resize(, 5).Merge
    .Value = "合計"
    .HorizontalAlignment = xlCenter
    With .Offset(, 1)
      .Resize(, 6).Formula _
        = "=SUM(" & _
          sh.Range(.EntireColumn.Cells(2, 1), _
            .Offset(-1, 0)).Address(0, 0) & ")"
      .Offset(, 4).ClearContents
    End With
  End With
  ActiveSheet.UsedRange.Borders.LineStyle = False
  Range("D1", Range("a" & Rows.Count).End(xlUp)).Resize(, 11).Borders.LineStyle = True
  Columns("A:N").EntireColumn.AutoFit
 MsgBox "申請リスト完成"
End Sub
・ツリー全体表示

【75225】Re:助けてください。最終行に合計を求め...
回答  ウッシ  - 14/1/9(木) 9:32 -

引用なし
パスワード
   ▼きおら さん:

こんにちは

>A列最終行セルからC列最終行セルの範囲内で中央揃えに

の意味が分かりません。
ひょっとしてセルを結合して中央揃えではないですか?

> For i = 4 To 7
> j = Application.Max(j, Cells(1048576, i).End(xlUp).Row + 1)
> Next

は何のために必要なのですか?
D〜G列の各列の最下行の一つ下の行数を求めているようですが
質問では「A列最終行セル」と言っているのでA列最終行セルの一つ下の行に
「合計」という文言と、「合計式」をセットすればよいのではないですか?

勝手に判断してコード化すると、

Sub test()
  Dim sh As Worksheet
  Set sh = ThisWorkbook.Worksheets("申請")
  With sh.Range("A" & Rows.Count).End(xlUp).Offset(1)
    .Resize(, 3).Merge
    .Value = "合計"
    .HorizontalAlignment = xlCenter
    With .Offset(, 1)
      .Resize(, 4).Formula _
        = "=SUM(" & _
          sh.Range(.EntireColumn.Cells(2, 1), _
            .Offset(-1, 0)).Address(0, 0) & ")"
      .Offset(, 2).ClearContents
    End With
  End With
End Sub

こんな感じになります。
・ツリー全体表示

【75224】Re:助けてください。最終行に合計を求め...
発言  γ  - 14/1/9(木) 7:49 -

引用なし
パスワード
   totalRow = Application.Max(totalRow, Cells(1048576, i).End(xlUp).Row + 1)

totalRow = Application.Max(totalRow, Cells(Rows.Count, i).End(xlUp).Row + 1)
としたほうがよい。見過ごしていました。
・ツリー全体表示

【75223】Re:助けてください。最終行に合計を求め...
発言  γ  - 14/1/9(木) 7:44 -

引用なし
パスワード
   模範でもないが、こうも書けますね。
Sub 合計行()
  Dim i As Long
  Dim totalRow As Long

  Worksheets("申請").Activate
  For i = 4 To 7
    totalRow = Application.Max(totalRow, Cells(1048576, i).End(xlUp).Row + 1)
  Next  'E列からG列でどれが最下行か不明ということですね?

  For i = 4 To 7
    Cells(totalRow, i).FormulaR1C1 = "=SUM(R2C:R[-1]C)"
  Next i
  Cells(totalRow, "F").ClearContents   'F行には合計は不要?
  
  Cells(totalRow, 1).FormulaR1C1 = "合計"
  Cells(totalRow, 1).Resize(1, 3).HorizontalAlignment = xlCenter
End Sub
・ツリー全体表示

【75222】助けてください。最終行に合計を求め書式...
質問  きおら  - 14/1/9(木) 2:07 -

引用なし
パスワード
   VBA初心者ですが、合計を求めるマクロを調べて作ってみました。
下記のような表です。
1.行数は増減します。
2.A列最終行に合計と入力し、A列最終行セルからC列最終行セルの
3.範囲内で中央揃えに。合計を求めたい列はDとEとGです。
☆出来れば部分的指導ではなく、模範的なものを教えていただけると
うれしいです。


A   B    C    D    E   F    G
氏名 住所 生年月日 口数 寄付金額 入金日 入金金額


↓↓このように書いて動かしましたが、途中で止まります。
どうかご教授お願いします。


Sub 合計行()

Dim i As Integer
Dim j As Long

Worksheets("申請").Activate
For i = 4 To 7
j = Application.Max(j, Cells(1048576, i).End(xlUp).Row + 1)
Next

For i = 4 To 7
Cells(j, i).FormulaR1C1 = "=SUM(R2C[0]:R[-1]C[0])"
Next i

Cells(j, 1).FormulaR1C1 = "合計"
    '合計行
    With .Range("a1").Offset(dic.Count + 1)

    End With

End Sub
・ツリー全体表示

【75221】Re:別ファイルへの貼り付けができない。
回答    - 14/1/8(水) 20:30 -

引用なし
パスワード
   こんにちは。

> Set xlApp = New Excel.Application
> Set xlBook = xlApp.Workbooks.Open(BBB.xlsのパス)
なぜこんなことをするのですか?
これは、理解できないままに使うコードではありません。

素直に下記でよいのではありませんか。
 Set xlBook = Workbooks.Open Filename:=BBB.xlsのパス
・ツリー全体表示

【75220】Re:複数の範囲(膨大)を、変数に取り込む
お礼  初心者M  - 14/1/8(水) 18:04 -

引用なし
パスワード
   kanabun様

すぐに確認したところ、完璧に動いているようです。
大変ありがとうございます。

真ん中の列に関しては、今度こそ自分でやってみようと思います。

お暇で無いでしょうに、貴重なお時間を割いてくださったことに、心より感謝いたします。
・ツリー全体表示

【75219】Re:複数の範囲(膨大)を、変数に取り込む
発言  kanabun  - 14/1/8(水) 18:01 -

引用なし
パスワード
   ▼初心者M さん:
> DやGに入る「2」や「4」の数字は、かけるのでなく割るのに使います。ここの処理までは、個人的には諦めていました。
>
>
>  C D  E F G H
>8
>
>9 15   2000 15   1800
>
>10
>
>11
>
>12 17   5900 17 2 11800
>
>
とりあえず、3列のうち、中央の列のことは無視して、C列、F列に何か記号が
入っていれば、その記号別に第3列(E列、H列...)の数値の最大値を振り当てる
というコードです。
つまり、Sub test3() を3か所修正しただけのコードです。
Sub test4()
  Dim n As Long
  Dim y As Long, x As Long
  Dim ss As String
  Dim c As Range
  Const Y0 = 8, YY = 25, Ystp = 16 '縦方向 最初の行番、繰り返し回数,Step
  Const X0 = 3, XX = 27, Xstp = 3 '列方向 最初の列番、繰り返し回数,Step
  Dim dic As Object
  Set dic = CreateObject("Scripting.Dictionary")
  
  For x = X0 To X0 + (XX - 1) * Xstp Step Xstp
   For y = Y0 To Y0 + (YY - 1) * Ystp Step Ystp
     For Each c In Cells(y, x).Resize(9)
      ss = c.Value
      If Len(ss) > 0 Then
       n = c.Offset(, 2).Value
       If Not dic.Exists(ss) Then
         dic(ss) = n
       ElseIf dic(ss) < n Then
         dic(ss) = n
       End If
      End If
     Next
    Next
  Next
  For x = X0 To X0 + (XX - 1) * Xstp Step Xstp
   For y = Y0 To Y0 + (YY - 1) * Ystp Step Ystp
     For Each c In Cells(y, x).Resize(9)
      ss = c.Value
      If Len(ss) > 0 Then
        c.Offset(, 2).Value = dic(ss)
      End If
     Next
    Next
  Next
  
End Sub
・ツリー全体表示

【75218】Re:複数の範囲(膨大)を、変数に取り込む
発言  初心者M  - 14/1/8(水) 17:51 -

引用なし
パスワード
   kanabun様

大変申し訳ございませんでした。
このような感じになります。先ほど勘違いしていましたが、DやGに入る「2」や「4」の数字は、かけるのでなく割るのに使います。ここの処理までは、個人的には諦めていました。


  C D  E F G H


9 15   2000 15   1800

10

11

12 17   5900 17 2 11800


これで伝わりますでしょうか。
ヒントだけでもいただければ大変嬉しいです。

どうぞよろしくお願いいたします。
・ツリー全体表示

【75217】Re:複数の範囲(膨大)を、変数に取り込む
発言  kanabun  - 14/1/8(水) 17:33 -

引用なし
パスワード
   ▼初心者M さん:

>大っっ変申し訳ございません。根本的に私の説明がマズかったです。昨日とファイルが変わったのですが、配列の取り込みしか頭に無かったのできちんと説明をしていませんでした。
>
>C8の縦行に(9行の中に、データは飛び飛びで入ります。1列だけのことも多いです)1,2などの数字(時には記号)が入り、E8の縦行に「7600」などの数値が入ります。

>
>もっと言うと、D8の列には「2」や「4」といった数字が入ることがあり、その場合はE8の数値がそれをかけた数字になります。
>これは、外注先の工場に送る仕様書の作成作業です。

では、列番号付きで、C,D,E列の最初のブロックだけでも、サンプルデータを
見せてください。
・ツリー全体表示

【75216】Re:複数の範囲(膨大)を、変数に取り込む
発言  初心者M  - 14/1/8(水) 17:22 -

引用なし
パスワード
   ▼kanabun様


>[C8] は部数?(数値)が書いてあるんではないですか?
>数値以外の記号のこともあるんですか?

大っっ変申し訳ございません。根本的に私の説明がマズかったです。昨日とファイルが変わったのですが、配列の取り込みしか頭に無かったのできちんと説明をしていませんでした。

C8の縦行に(9行の中に、データは飛び飛びで入ります。1列だけのことも多いです)1,2などの数字(時には記号)が入り、E8の縦行に「7600」などの数値が入ります。

(私の仕事ではないのですが)この表では、数の近いものを人間の目で見て照らし合わせて、近くにある最適なものと同じ記号で付け合せをするんです。その後、手動でその中の一番大きな数字の物に入力し直すという作業をするのですが、これが見ていて大変そうだったので、なんとか自動化して楽にさせてあげたいという気持ちから、密かにやっていることでした。

もっと言うと、D8の列には「2」や「4」といった数字が入ることがあり、その場合はE8の数値がそれをかけた数字になります。
これは、外注先の工場に送る仕様書の作成作業です。

データが数値であれば、longが最善なのはなんとか理解できます。
・ツリー全体表示

359 / 3841 ページ ←次へ | 前へ→
ページ:  ┃  記事番号:
2610219
(SS)C-BOARD v3.8 is Free