Excel根据日期查找行号

n9vozmp4  于 2023-05-19  发布在  其他
关注(0)|答案(1)|浏览(194)

我在想怎么根据日期得到行号。
我在Excel中在一个工作表上构建了一个日历,同时使用另一个工作表作为表格,其中A1:NB1是日期。
示例:x1c 0d1x
我正在使用以下公式为我提供与单元格选择日期相关联的列编号=IFERROR(MATCH(M3,INDIRECT("'"&ScYear&"'!A1:NB1",TRUE),0),"")
示例:

我想要一种方法来标识日历上选择的行号与表日期列中的第一个可用行。
例如,如果我在日历中选择今天日期的第一个单元格,它会报告第1行,因为这是第一个空白单元格。如果我选择今天日期下面的第二个单元格,它会选择第二行,一直到第九行。
任何帮助将不胜感激!

jdgnovmf

jdgnovmf1#

在VBA中,我使用了这个冗长而不优雅的解决方案来获得我想要的基于target.value的行。
通过“手动”让它识别所选的目标地址,我可以让它识别所选的行,并将该值写入Range("M43"),然后使用类似于以下Sheets("" & DbSht & "").Cells(DbRow + 1, DbCol).Value = Target.Value的代码识别需要更新的列和行。(DbRow = M43中的值,DbCol = M42中的值,其为列号和行号)。
可能有一种更简单的方法通过一个模块来使用索引或匹配,但这个解决方案目前有效。希望这比我最初的问题更有意义。
只是代码的一个示例,不是全部,太长了:

If Target.Row = 6 And Target.Column = 4 Then
Range("M43").Value = 1
Range("B7").Value = Target.Address
ElseIf Target.Row = 6 And Target.Column = 5 Then
Range("M43").Value = 1
Range("B7").Value = Target.Address
ElseIf Target.Row = 6 And Target.Column = 6 Then
Range("M43").Value = 1
Range("B7").Value = Target.Address
ElseIf Target.Row = 6 And Target.Column = 7 Then
Range("M43").Value = 1
Range("B7").Value = Target.Address
ElseIf Target.Row = 6 And Target.Column = 8 Then
Range("M43").Value = 1
Range("B7").Value = Target.Address
ElseIf Target.Row = 6 And Target.Column = 9 Then
Range("M43").Value = 1
Range("B7").Value = Target.Address
ElseIf Target.Row = 6 And Target.Column = 10 Then
Range("M43").Value = 1
Range("B7").Value = Target.Address

ElseIf Target.Row = 7 And Target.Column = 4 Then
Range("M43").Value = 2
Range("B7").Value = Target.Offset(-1, 0).Address
ElseIf Target.Row = 7 And Target.Column = 5 Then
Range("M43").Value = 2
Range("B7").Value = Target.Offset(-1, 0).Address
ElseIf Target.Row = 7 And Target.Column = 6 Then
Range("M43").Value = 2
Range("B7").Value = Target.Offset(-1, 0).Address
ElseIf Target.Row = 7 And Target.Column = 7 Then
Range("M43").Value = 2
Range("B7").Value = Target.Offset(-1, 0).Address
ElseIf Target.Row = 7 And Target.Column = 8 Then
Range("M43").Value = 2
Range("B7").Value = Target.Offset(-1, 0).Address
ElseIf Target.Row = 7 And Target.Column = 9 Then
Range("M43").Value = 2
Range("B7").Value = Target.Offset(-1, 0).Address
ElseIf Target.Row = 7 And Target.Column = 10 Then
Range("M43").Value = 2
Range("B7").Value = Target.Offset(-1, 0).Address

ElseIf Target.Row = 8 And Target.Column = 4 Then
Range("M43").Value = 3
Range("B7").Value = Target.Offset(-2, 0).Address
ElseIf Target.Row = 8 And Target.Column = 5 Then
Range("M43").Value = 3
Range("B7").Value = Target.Offset(-2, 0).Address
ElseIf Target.Row = 8 And Target.Column = 6 Then
Range("M43").Value = 3
Range("B7").Value = Target.Offset(-2, 0).Address
ElseIf Target.Row = 8 And Target.Column = 7 Then
Range("M43").Value = 3
Range("B7").Value = Target.Offset(-2, 0).Address
ElseIf Target.Row = 8 And Target.Column = 8 Then
Range("M43").Value = 3
Range("B7").Value = Target.Offset(-2, 0).Address
ElseIf Target.Row = 8 And Target.Column = 9 Then
Range("M43").Value = 3
Range("B7").Value = Target.Offset(-2, 0).Address
ElseIf Target.Row = 8 And Target.Column = 10 Then
Range("M43").Value = 3
Range("B7").Value = Target.Offset(-2, 0).Address

ElseIf Target.Row = 9 And Target.Column = 4 Then
Range("M43").Value = 4
Range("B7").Value = Target.Offset(-3, 0).Address
ElseIf Target.Row = 9 And Target.Column = 5 Then
Range("M43").Value = 4
Range("B7").Value = Target.Offset(-3, 0).Address
ElseIf Target.Row = 9 And Target.Column = 6 Then
Range("M43").Value = 4
Range("B7").Value = Target.Offset(-3, 0).Address
ElseIf Target.Row = 9 And Target.Column = 7 Then
Range("M43").Value = 4
Range("B7").Value = Target.Offset(-3, 0).Address
ElseIf Target.Row = 9 And Target.Column = 8 Then
Range("M43").Value = 4
Range("B7").Value = Target.Offset(-3, 0).Address
ElseIf Target.Row = 9 And Target.Column = 9 Then
Range("M43").Value = 4
Range("B7").Value = Target.Offset(-3, 0).Address
ElseIf Target.Row = 9 And Target.Column = 10 Then
Range("M43").Value = 4
Range("B7").Value = Target.Offset(-3, 0).Address

ElseIf Target.Row = 10 And Target.Column = 4 Then
Range("M43").Value = 5
Range("B7").Value = Target.Offset(-4, 0).Address
ElseIf Target.Row = 10 And Target.Column = 5 Then
Range("M43").Value = 5
Range("B7").Value = Target.Offset(-4, 0).Address
ElseIf Target.Row = 10 And Target.Column = 6 Then
Range("M43").Value = 5
Range("B7").Value = Target.Offset(-4, 0).Address
ElseIf Target.Row = 10 And Target.Column = 7 Then
Range("M43").Value = 5
Range("B7").Value = Target.Offset(-4, 0).Address
ElseIf Target.Row = 10 And Target.Column = 8 Then
Range("M43").Value = 5
Range("B7").Value = Target.Offset(-4, 0).Address
ElseIf Target.Row = 10 And Target.Column = 9 Then
Range("M43").Value = 5
Range("B7").Value = Target.Offset(-4, 0).Address
ElseIf Target.Row = 10 And Target.Column = 10 Then
Range("M43").Value = 5
Range("B7").Value = Target.Offset(-4, 0).Address

ElseIf Target.Row = 11 And Target.Column = 4 Then
Range("M43").Value = 6
Range("B7").Value = Target.Offset(-5, 0).Address
ElseIf Target.Row = 11 And Target.Column = 5 Then
Range("M43").Value = 6
Range("B7").Value = Target.Offset(-5, 0).Address
ElseIf Target.Row = 11 And Target.Column = 6 Then
Range("M43").Value = 6
Range("B7").Value = Target.Offset(-5, 0).Address
ElseIf Target.Row = 11 And Target.Column = 7 Then
Range("M43").Value = 6
Range("B7").Value = Target.Offset(-5, 0).Address
ElseIf Target.Row = 11 And Target.Column = 8 Then
Range("M43").Value = 6
Range("B7").Value = Target.Offset(-5, 0).Address
ElseIf Target.Row = 11 And Target.Column = 9 Then
Range("M43").Value = 6
Range("B7").Value = Target.Offset(-5, 0).Address
ElseIf Target.Row = 11 And Target.Column = 10 Then
Range("M43").Value = 6
Range("B7").Value = Target.Offset(-5, 0).Address

ElseIf Target.Row = 12 And Target.Column = 4 Then
Range("M43").Value = 7
Range("B7").Value = Target.Offset(-6, 0).Address
ElseIf Target.Row = 12 And Target.Column = 5 Then
Range("M43").Value = 7
Range("B7").Value = Target.Offset(-6, 0).Address
ElseIf Target.Row = 12 And Target.Column = 6 Then
Range("M43").Value = 7
Range("B7").Value = Target.Offset(-6, 0).Address
ElseIf Target.Row = 12 And Target.Column = 7 Then
Range("M43").Value = 7
Range("B7").Value = Target.Offset(-6, 0).Address
ElseIf Target.Row = 12 And Target.Column = 8 Then
Range("M43").Value = 7
Range("B7").Value = Target.Offset(-6, 0).Address
ElseIf Target.Row = 12 And Target.Column = 9 Then
Range("M43").Value = 7
Range("B7").Value = Target.Offset(-6, 0).Address
ElseIf Target.Row = 12 And Target.Column = 10 Then
Range("M43").Value = 7
Range("B7").Value = Target.Offset(-6, 0).Address

ElseIf Target.Row = 13 And Target.Column = 4 Then
Range("M43").Value = 8
Range("B7").Value = Target.Offset(-7, 0).Address
ElseIf Target.Row = 13 And Target.Column = 5 Then
Range("M43").Value = 8
Range("B7").Value = Target.Offset(-7, 0).Address
ElseIf Target.Row = 13 And Target.Column = 6 Then
Range("M43").Value = 8
Range("B7").Value = Target.Offset(-7, 0).Address
ElseIf Target.Row = 13 And Target.Column = 7 Then
Range("M43").Value = 8
Range("B7").Value = Target.Offset(-7, 0).Address
ElseIf Target.Row = 13 And Target.Column = 8 Then
Range("M43").Value = 8
Range("B7").Value = Target.Offset(-7, 0).Address
ElseIf Target.Row = 13 And Target.Column = 9 Then
Range("M43").Value = 8
Range("B7").Value = Target.Offset(-7, 0).Address
ElseIf Target.Row = 13 And Target.Column = 10 Then
Range("M43").Value = 8
Range("B7").Value = Target.Offset(-7, 0).Address
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ElseIf Target.Row = 15 And Target.Column = 4 Then
Range("M43").Value = 1
Range("B7").Value = Target.Address
ElseIf Target.Row = 15 And Target.Column = 5 Then
Range("M43").Value = 1
Range("B7").Value = Target.Address
ElseIf Target.Row = 15 And Target.Column = 6 Then
Range("M43").Value = 1
Range("B7").Value = Target.Address
ElseIf Target.Row = 15 And Target.Column = 7 Then
Range("M43").Value = 1
Range("B7").Value = Target.Address
ElseIf Target.Row = 15 And Target.Column = 8 Then
Range("M43").Value = 1
Range("B7").Value = Target.Address
ElseIf Target.Row = 15 And Target.Column = 9 Then
Range("M43").Value = 1
Range("B7").Value = Target.Address
ElseIf Target.Row = 15 And Target.Column = 10 Then
Range("M43").Value = 1
Range("B7").Value = Target.Address

ElseIf Target.Row = 16 And Target.Column = 4 Then
Range("M43").Value = 2
Range("B7").Value = Target.Offset(-1, 0).Address
ElseIf Target.Row = 16 And Target.Column = 5 Then
Range("M43").Value = 2
Range("B7").Value = Target.Offset(-1, 0).Address
ElseIf Target.Row = 16 And Target.Column = 6 Then
Range("M43").Value = 2
Range("B7").Value = Target.Offset(-1, 0).Address
ElseIf Target.Row = 16 And Target.Column = 7 Then
Range("M43").Value = 2
Range("B7").Value = Target.Offset(-1, 0).Address
ElseIf Target.Row = 16 And Target.Column = 8 Then
Range("M43").Value = 2
Range("B7").Value = Target.Offset(-1, 0).Address
ElseIf Target.Row = 16 And Target.Column = 9 Then
Range("M43").Value = 2
Range("B7").Value = Target.Offset(-1, 0).Address
ElseIf Target.Row = 16 And Target.Column = 10 Then
Range("M43").Value = 2
Range("B7").Value = Target.Offset(-1, 0).Address

ElseIf Target.Row = 17 And Target.Column = 4 Then
Range("M43").Value = 3
Range("B7").Value = Target.Offset(-2, 0).Address
ElseIf Target.Row = 17 And Target.Column = 5 Then
Range("M43").Value = 3
Range("B7").Value = Target.Offset(-2, 0).Address
ElseIf Target.Row = 17 And Target.Column = 6 Then
Range("M43").Value = 3
Range("B7").Value = Target.Offset(-2, 0).Address
ElseIf Target.Row = 17 And Target.Column = 7 Then
Range("M43").Value = 3
Range("B7").Value = Target.Offset(-2, 0).Address
ElseIf Target.Row = 17 And Target.Column = 8 Then
Range("M43").Value = 3
Range("B7").Value = Target.Offset(-2, 0).Address
ElseIf Target.Row = 17 And Target.Column = 9 Then
Range("M43").Value = 3
Range("B7").Value = Target.Offset(-2, 0).Address
ElseIf Target.Row = 17 And Target.Column = 10 Then
Range("M43").Value = 3
Range("B7").Value = Target.Offset(-2, 0).Address

ElseIf Target.Row = 18 And Target.Column = 4 Then
Range("M43").Value = 4
Range("B7").Value = Target.Offset(-3, 0).Address
ElseIf Target.Row = 18 And Target.Column = 5 Then
Range("M43").Value = 4
Range("B7").Value = Target.Offset(-3, 0).Address
ElseIf Target.Row = 18 And Target.Column = 6 Then
Range("M43").Value = 4
Range("B7").Value = Target.Offset(-3, 0).Address
ElseIf Target.Row = 18 And Target.Column = 7 Then
Range("M43").Value = 4
Range("B7").Value = Target.Offset(-3, 0).Address
ElseIf Target.Row = 18 And Target.Column = 8 Then
Range("M43").Value = 4
Range("B7").Value = Target.Offset(-3, 0).Address
ElseIf Target.Row = 18 And Target.Column = 9 Then
Range("M43").Value = 4
Range("B7").Value = Target.Offset(-3, 0).Address
ElseIf Target.Row = 18 And Target.Column = 10 Then
Range("M43").Value = 4
Range("B7").Value = Target.Offset(-3, 0).Address

ElseIf Target.Row = 19 And Target.Column = 4 Then
Range("M43").Value = 5
Range("B7").Value = Target.Offset(-4, 0).Address
ElseIf Target.Row = 19 And Target.Column = 5 Then
Range("M43").Value = 5
Range("B7").Value = Target.Offset(-4, 0).Address
ElseIf Target.Row = 19 And Target.Column = 6 Then
Range("M43").Value = 5
Range("B7").Value = Target.Offset(-4, 0).Address
ElseIf Target.Row = 19 And Target.Column = 7 Then
Range("M43").Value = 5
Range("B7").Value = Target.Offset(-4, 0).Address
ElseIf Target.Row = 19 And Target.Column = 8 Then
Range("M43").Value = 5
Range("B7").Value = Target.Offset(-4, 0).Address
ElseIf Target.Row = 19 And Target.Column = 9 Then
Range("M43").Value = 5
Range("B7").Value = Target.Offset(-4, 0).Address
ElseIf Target.Row = 19 And Target.Column = 10 Then
Range("M43").Value = 5
Range("B7").Value = Target.Offset(-4, 0).Address

ElseIf Target.Row = 20 And Target.Column = 4 Then
Range("M43").Value = 6
Range("B7").Value = Target.Offset(-5, 0).Address
ElseIf Target.Row = 20 And Target.Column = 5 Then
Range("M43").Value = 6
Range("B7").Value = Target.Offset(-5, 0).Address
ElseIf Target.Row = 20 And Target.Column = 6 Then
Range("M43").Value = 6
Range("B7").Value = Target.Offset(-5, 0).Address
ElseIf Target.Row = 20 And Target.Column = 7 Then
Range("M43").Value = 6
Range("B7").Value = Target.Offset(-5, 0).Address
ElseIf Target.Row = 20 And Target.Column = 8 Then
Range("M43").Value = 6
Range("B7").Value = Target.Offset(-5, 0).Address
ElseIf Target.Row = 20 And Target.Column = 9 Then
Range("M43").Value = 6
Range("B7").Value = Target.Offset(-5, 0).Address
ElseIf Target.Row = 20 And Target.Column = 10 Then
Range("M43").Value = 6
Range("B7").Value = Target.Offset(-5, 0).Address

ElseIf Target.Row = 21 And Target.Column = 4 Then
Range("M43").Value = 7
Range("B7").Value = Target.Offset(-6, 0).Address
ElseIf Target.Row = 21 And Target.Column = 5 Then
Range("M43").Value = 7
Range("B7").Value = Target.Offset(-6, 0).Address
ElseIf Target.Row = 21 And Target.Column = 6 Then
Range("M43").Value = 7
Range("B7").Value = Target.Offset(-6, 0).Address
ElseIf Target.Row = 21 And Target.Column = 7 Then
Range("M43").Value = 7
Range("B7").Value = Target.Offset(-6, 0).Address
ElseIf Target.Row = 21 And Target.Column = 8 Then
Range("M43").Value = 7
Range("B7").Value = Target.Offset(-6, 0).Address
ElseIf Target.Row = 21 And Target.Column = 9 Then
Range("M43").Value = 7
Range("B7").Value = Target.Offset(-6, 0).Address
ElseIf Target.Row = 21 And Target.Column = 10 Then
Range("M43").Value = 7
Range("B7").Value = Target.Offset(-6, 0).Address

ElseIf Target.Row = 22 And Target.Column = 4 Then
Range("M43").Value = 8
Range("B7").Value = Target.Offset(-7, 0).Address
ElseIf Target.Row = 22 And Target.Column = 5 Then
Range("M43").Value = 8
Range("B7").Value = Target.Offset(-7, 0).Address
ElseIf Target.Row = 22 And Target.Column = 6 Then
Range("M43").Value = 8
Range("B7").Value = Target.Offset(-7, 0).Address
ElseIf Target.Row = 22 And Target.Column = 7 Then
Range("M43").Value = 8
Range("B7").Value = Target.Offset(-7, 0).Address
ElseIf Target.Row = 22 And Target.Column = 8 Then
Range("M43").Value = 8
Range("B7").Value = Target.Offset(-7, 0).Address
ElseIf Target.Row = 22 And Target.Column = 9 Then
Range("M43").Value = 8
Range("B7").Value = Target.Offset(-7, 0).Address
ElseIf Target.Row = 22 And Target.Column = 10 Then
Range("M43").Value = 8
Range("B7").Value = Target.Offset(-7, 0).Address

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ElseIf Target.Row = 24 And Target.Column = 4 Then
Range("M43").Value = 1
Range("B7").Value = Target.Address
ElseIf Target.Row = 24 And Target.Column = 5 Then
Range("M43").Value = 1
Range("B7").Value = Target.Address
ElseIf Target.Row = 24 And Target.Column = 6 Then
Range("M43").Value = 1
Range("B7").Value = Target.Address
ElseIf Target.Row = 24 And Target.Column = 7 Then
Range("M43").Value = 1
Range("B7").Value = Target.Address
ElseIf Target.Row = 24 And Target.Column = 8 Then
Range("M43").Value = 1
Range("B7").Value = Target.Address
ElseIf Target.Row = 24 And Target.Column = 9 Then
Range("M43").Value = 1
Range("B7").Value = Target.Address
ElseIf Target.Row = 24 And Target.Column = 10 Then
Range("M43").Value = 1
Range("B7").Value = Target.Address

ElseIf Target.Row = 25 And Target.Column = 4 Then
Range("M43").Value = 2
Range("B7").Value = Target.Offset(-1, 0).Address
ElseIf Target.Row = 25 And Target.Column = 5 Then
Range("M43").Value = 2
Range("B7").Value = Target.Offset(-1, 0).Address
ElseIf Target.Row = 25 And Target.Column = 6 Then
Range("M43").Value = 2
Range("B7").Value = Target.Offset(-1, 0).Address
ElseIf Target.Row = 25 And Target.Column = 7 Then
Range("M43").Value = 2
Range("B7").Value = Target.Offset(-1, 0).Address
ElseIf Target.Row = 25 And Target.Column = 8 Then
Range("M43").Value = 2
Range("B7").Value = Target.Offset(-1, 0).Address
ElseIf Target.Row = 25 And Target.Column = 9 Then
Range("M43").Value = 2
Range("B7").Value = Target.Offset(-1, 0).Address
ElseIf Target.Row = 25 And Target.Column = 10 Then
Range("M43").Value = 2
Range("B7").Value = Target.Offset(-1, 0).Address

ElseIf Target.Row = 26 And Target.Column = 4 Then
Range("M43").Value = 3
Range("B7").Value = Target.Offset(-2, 0).Address
ElseIf Target.Row = 26 And Target.Column = 5 Then
Range("M43").Value = 3
Range("B7").Value = Target.Offset(-2, 0).Address
ElseIf Target.Row = 26 And Target.Column = 6 Then
Range("M43").Value = 3
Range("B7").Value = Target.Offset(-2, 0).Address
ElseIf Target.Row = 26 And Target.Column = 7 Then
Range("M43").Value = 3
Range("B7").Value = Target.Offset(-2, 0).Address
ElseIf Target.Row = 26 And Target.Column = 8 Then
Range("M43").Value = 3
Range("B7").Value = Target.Offset(-2, 0).Address
ElseIf Target.Row = 26 And Target.Column = 9 Then
Range("M43").Value = 3
Range("B7").Value = Target.Offset(-2, 0).Address
ElseIf Target.Row = 26 And Target.Column = 10 Then
Range("M43").Value = 3
Range("B7").Value = Target.Offset(-2, 0).Address

ElseIf Target.Row = 27 And Target.Column = 4 Then
Range("M43").Value = 4
Range("B7").Value = Target.Offset(-3, 0).Address
ElseIf Target.Row = 27 And Target.Column = 5 Then
Range("M43").Value = 4
Range("B7").Value = Target.Offset(-3, 0).Address
ElseIf Target.Row = 27 And Target.Column = 6 Then
Range("M43").Value = 4
Range("B7").Value = Target.Offset(-3, 0).Address
ElseIf Target.Row = 27 And Target.Column = 7 Then
Range("M43").Value = 4
Range("B7").Value = Target.Offset(-3, 0).Address
ElseIf Target.Row = 27 And Target.Column = 8 Then
Range("M43").Value = 4
Range("B7").Value = Target.Offset(-3, 0).Address
ElseIf Target.Row = 27 And Target.Column = 9 Then
Range("M43").Value = 4
Range("B7").Value = Target.Offset(-3, 0).Address
ElseIf Target.Row = 27 And Target.Column = 10 Then
Range("M43").Value = 4
Range("B7").Value = Target.Offset(-3, 0).Address

ElseIf Target.Row = 28 And Target.Column = 4 Then
Range("M43").Value = 5
Range("B7").Value = Target.Offset(-4, 0).Address
ElseIf Target.Row = 28 And Target.Column = 5 Then
Range("M43").Value = 5
Range("B7").Value = Target.Offset(-4, 0).Address
ElseIf Target.Row = 28 And Target.Column = 6 Then
Range("M43").Value = 5
Range("B7").Value = Target.Offset(-4, 0).Address
ElseIf Target.Row = 28 And Target.Column = 7 Then
Range("M43").Value = 5
Range("B7").Value = Target.Offset(-4, 0).Address
ElseIf Target.Row = 28 And Target.Column = 8 Then
Range("M43").Value = 5
Range("B7").Value = Target.Offset(-4, 0).Address
ElseIf Target.Row = 28 And Target.Column = 9 Then
Range("M43").Value = 5
Range("B7").Value = Target.Offset(-4, 0).Address
ElseIf Target.Row = 28 And Target.Column = 10 Then
Range("M43").Value = 5
Range("B7").Value = Target.Offset(-4, 0).Address

ElseIf Target.Row = 29 And Target.Column = 4 Then
Range("M43").Value = 6
Range("B7").Value = Target.Offset(-5, 0).Address
ElseIf Target.Row = 29 And Target.Column = 5 Then
Range("M43").Value = 6
Range("B7").Value = Target.Offset(-5, 0).Address
ElseIf Target.Row = 29 And Target.Column = 6 Then
Range("M43").Value = 6
Range("B7").Value = Target.Offset(-5, 0).Address
ElseIf Target.Row = 29 And Target.Column = 7 Then
Range("M43").Value = 6
Range("B7").Value = Target.Offset(-5, 0).Address
ElseIf Target.Row = 29 And Target.Column = 8 Then
Range("M43").Value = 6
Range("B7").Value = Target.Offset(-5, 0).Address
ElseIf Target.Row = 29 And Target.Column = 9 Then
Range("M43").Value = 6
Range("B7").Value = Target.Offset(-5, 0).Address
ElseIf Target.Row = 29 And Target.Column = 10 Then
Range("M43").Value = 6
Range("B7").Value = Target.Offset(-5, 0).Address

ElseIf Target.Row = 30 And Target.Column = 4 Then
Range("M43").Value = 7
Range("B7").Value = Target.Offset(-6, 0).Address
ElseIf Target.Row = 30 And Target.Column = 5 Then
Range("M43").Value = 7
Range("B7").Value = Target.Offset(-6, 0).Address
ElseIf Target.Row = 30 And Target.Column = 6 Then
Range("M43").Value = 7
Range("B7").Value = Target.Offset(-6, 0).Address
ElseIf Target.Row = 30 And Target.Column = 7 Then
Range("M43").Value = 7
Range("B7").Value = Target.Offset(-6, 0).Address
ElseIf Target.Row = 30 And Target.Column = 8 Then
Range("M43").Value = 7
Range("B7").Value = Target.Offset(-6, 0).Address
ElseIf Target.Row = 30 And Target.Column = 9 Then
Range("M43").Value = 7
Range("B7").Value = Target.Offset(-6, 0).Address
ElseIf Target.Row = 30 And Target.Column = 10 Then
Range("M43").Value = 7
Range("B7").Value = Target.Offset(-6, 0).Address

ElseIf Target.Row = 31 And Target.Column = 4 Then
Range("M43").Value = 8
Range("B7").Value = Target.Offset(-7, 0).Address
ElseIf Target.Row = 31 And Target.Column = 5 Then
Range("M43").Value = 8
Range("B7").Value = Target.Offset(-7, 0).Address
ElseIf Target.Row = 31 And Target.Column = 6 Then
Range("M43").Value = 8
Range("B7").Value = Target.Offset(-7, 0).Address
ElseIf Target.Row = 31 And Target.Column = 7 Then
Range("M43").Value = 8
Range("B7").Value = Target.Offset(-7, 0).Address
ElseIf Target.Row = 31 And Target.Column = 8 Then
Range("M43").Value = 8
Range("B7").Value = Target.Offset(-7, 0).Address
ElseIf Target.Row = 31 And Target.Column = 9 Then
Range("M43").Value = 8
Range("B7").Value = Target.Offset(-7, 0).Address
ElseIf Target.Row = 31 And Target.Column = 10 Then
Range("M43").Value = 8
Range("B7").Value = Target.Offset(-7, 0).Address
End If

相关问题