[ 初めての方へ | 一覧(最新更新順) | 全文検索 | 過去ログ ]
『なおしてもらえませんか?』(こーた)
Sub test()
Dim i As Integer
For i = 1 To 100
If Cells(i, 1).Value = "" Then
Cells(i, 1).Value = "仕入"
End If
Next i
End Sub
=F6:L6のセル範囲になおしたいのですがよろしくお願いします
< 使用 Excel:Excel2003、使用 OS:WindowsXP >
Sub test() Dim i As Integer, Cel As Range
For Each Cel In Range("F6:L6")
If Cel.Value = "" Then Cel.Value = "仕入" End If Next End Sub (半平太) 2017/09/12(火) 12:22
質問の趣旨が不明瞭なので・・・
シートモジュールに書く「イベントプロシージャ」について調べてみてください、とだけアドバイスします。
こんな形式のものです ↓ Private Sub Worksheet_Change(ByVal Target as Range) ’処理 End Sub
それだけじゃ分からなくて、もっと具体的な回答が欲しい場合は、 他の回答者のレスが付くまでしばらくお待ちください。m(__)m
(半平太) 2017/09/12(火) 14:19
ということなら、1行追加するだけです。
Sub test() Dim Cel As Range
If Range("C6").Value="" then Exit Sub '★追加
For Each Cel In Range("F6:L6") If Cel.Value = "" Then Cel.Value = "仕入" End If Next
End Sub
(マナ) 2017/09/12(火) 20:50
Sub ボタン27_Click()
Dim Cel As Range
If Range("C6").Value = "" Then Exit Sub '★追加
For Each Cel In Range("F6:L6") If Cel.Value = "" Then Cel.Value = "公休" End If Next
If Range("C10").Value = "" Then Exit Sub '★追加
For Each Cel In Range("F10:L10") If Cel.Value = "" Then Cel.Value = "公休" End If Next
If Range("C14").Value = "" Then Exit Sub '★追加
For Each Cel In Range("F14:L14") If Cel.Value = "" Then Cel.Value = "公休" End If Next
If Range("C18").Value = "" Then Exit Sub '★追加
For Each Cel In Range("F18:L18") If Cel.Value = "" Then Cel.Value = "公休" End If Next
If Range("C22").Value = "" Then Exit Sub '★追加
For Each Cel In Range("F22:L22") If Cel.Value = "" Then Cel.Value = "公休" End If Next
If Range("C26").Value = "" Then Exit Sub '★追加
For Each Cel In Range("F26:L26") If Cel.Value = "" Then Cel.Value = "公休" End If Next
If Range("C30").Value = "" Then Exit Sub '★追加
For Each Cel In Range("F30:L30") If Cel.Value = "" Then Cel.Value = "公休" End If Next
If Range("C34").Value = "" Then Exit Sub '★追加
For Each Cel In Range("F34:L34") If Cel.Value = "" Then Cel.Value = "公休" End If Next
If Range("C38").Value = "" Then Exit Sub '★追加
For Each Cel In Range("F38:L38") If Cel.Value = "" Then Cel.Value = "公休" End If Next
If Range("C42").Value = "" Then Exit Sub '★追加
For Each Cel In Range("F42:L42") If Cel.Value = "" Then Cel.Value = "公休" End If Next
If Range("C46").Value = "" Then Exit Sub '★追加
For Each Cel In Range("F46:L46") If Cel.Value = "" Then Cel.Value = "公休" End If Next
If Range("C50").Value = "" Then Exit Sub '★追加
For Each Cel In Range("F50:L50") If Cel.Value = "" Then Cel.Value = "公休" End If Next
If Range("C54").Value = "" Then Exit Sub '★追加
For Each Cel In Range("F54:L54") If Cel.Value = "" Then Cel.Value = "公休" End If Next
If Range("C58").Value = "" Then Exit Sub '★追加
For Each Cel In Range("F58:L58") If Cel.Value = "" Then Cel.Value = "公休" End If Next
If Range("C62").Value = "" Then Exit Sub '★追加
For Each Cel In Range("F62:L62") If Cel.Value = "" Then Cel.Value = "公休" End If Next
If Range("C66").Value = "" Then Exit Sub '★追加
For Each Cel In Range("F66:L66") If Cel.Value = "" Then Cel.Value = "公休" End If Next
If Range("C70").Value = "" Then Exit Sub '★追加
For Each Cel In Range("F70:L70") If Cel.Value = "" Then Cel.Value = "公休" End If Next
If Range("C74").Value = "" Then Exit Sub '★追加
For Each Cel In Range("F74:L74") If Cel.Value = "" Then Cel.Value = "公休" End If Next
End Sub
(こーた) 2017/09/12(火) 22:41
Sub test2() Dim Cel As Range
If Range("C6").Value <> "" Then
For Each Cel In Range("F6:L6") If Cel.Value = "" Then Cel.Value = "仕入" End If Next
End If
End Sub
>If Range("C6").Value = "" Then Exit Sub
これだと、「空白ならば、そこで終了」
これを、「空白でなければ、実行する」にします。
(マナ) 2017/09/12(火) 22:58
(こーた) 2017/09/12(火) 23:16
(こーた) 2017/09/12(火) 23:29
(マナ) 2017/09/12(火) 23:37
の意味じゃわかりませんが、
ゼロを表示しない設定で空白に見えているのなら、
If Range("C6").Value <> 0 Then
に変更してみてください。
(マナ) 2017/09/15(金) 19:15
[ 一覧(最新更新順) ]
YukiWiki 1.6.7 Copyright (C) 2000,2001 by Hiroshi Yuki.
Modified by kazu.