teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

.Valueをつけました

2021/10/01 22:36

投稿

syousuke.33
syousuke.33

スコア312

answer CHANGED
@@ -4,23 +4,24 @@
4
4
  Dim 日付 As Date
5
5
  Dim 家賃 As Long
6
6
  Dim 光熱費 As Long
7
+
7
8
  Dim 食費 As Long
8
- Dim i As Long, n As Long, m As Long
9
+ Dim i As Long, n As Long
9
10
  Sub Macro1()
10
11
 
11
12
  Sheets("入力").Select
12
- 日付 = Range("B2")
13
+ 日付 = Range("B2").Value
13
- 家賃 = Range("B3")
14
+ 家賃 = Range("B3").Value
14
- 光熱費 = Range("B4")
15
+ 光熱費 = Range("B4").Value
15
- 食費 = Range("B5")
16
+ 食費 = Range("B5").Value
16
17
 
17
18
  Sheets("家計簿").Select
18
19
  n = Cells(1, Columns.Count).End(xlToLeft).Column
19
20
  For i = 2 To n
20
21
  If 日付 = Cells(1, i) Then
21
- Cells(2, i) = 家賃
22
+ Cells(2, i).Value = 家賃
22
- Cells(3, i) = 光熱費
23
+ Cells(3, i).Value = 光熱費
23
- Cells(4, i) = 食費
24
+ Cells(4, i).Value = 食費
24
25
  Sheets("入力").Select
25
26
  Exit Sub
26
27
  End If