【发布时间】:2018-02-23 03:51:41
【问题描述】:
我正在尝试将 1 或 0 从一张“5s Audit”转移到另一张“Feb Aisle Score”取决于使用提交按钮执行的通过或失败,问题是我需要的位置通过或失败转移到将取决于日期或区域的特定单元格,如下拉列表中显示的图像(日期/区域)。
需要向下传递数据的工作表已修复,以将日期(1-31 月的每一天的数字)作为列,将区域作为行。如下图。
我试图做的是看看我是否可以使用 Dim 语句来启动它,但我一生都无法弄清楚以哪种方式将区域称为行,将日期称为列。
我已经设置了从“Dim Loc1 As String”开始的所有区域单元格和从“Dim Day1 As Double”开始的天数,并引用了每个单元格位置,包括 Sheet 1 中的前 2 个条件。
Sub Submit_Button()
Dim Loc1 As String
Dim Loc2 As String
Dim Loc3 As String
Dim Loc4 As String
Dim Loc5 As String
Dim Loc6 As String
Dim Loc7 As String
Dim Loc8 As String
Dim Loc9 As String
Dim Loc10 As String
Dim Loc11 As String
Dim Loc12 As String
Dim Loc13 As String
Dim Loc14 As String
Dim Loc15 As String
Dim Loc16 As String
Dim Loc17 As String
Dim Loc18 As String
Dim Loc19 As String
Dim Loc20 As String
Dim Loc21 As String
Dim Loc22 As String
Dim Loc23 As String
Dim Loc24 As String
Dim Loc25 As String
Dim Loc26 As String
Dim Loc27 As String
Dim Loc28 As String
Dim Loc29 As String
Dim Loc30 As String
Dim Loc31 As String
Dim Loc32 As String
Dim Loc33 As String
Dim Loc34 As String
Dim Loc35 As String
Dim Loc36 As String
Dim Day1 As Double
Dim Day2 As Double
Dim Day3 As Double
Dim Day4 As Double
Dim Day5 As Double
Dim Day6 As Double
Dim Day7 As Double
Dim Day8 As Double
Dim Day9 As Double
Dim Day10 As Double
Dim Day11 As Double
Dim Day12 As Double
Dim Day13 As Double
Dim Day14 As Double
Dim Day15 As Double
Dim Day16 As Double
Dim Day17 As Double
Dim Day18 As Double
Dim Day19 As Double
Dim Day20 As Double
Dim Day21 As Double
Dim Day22 As Double
Dim Day23 As Double
Dim Day24 As Double
Dim Day25 As Double
Dim Day26 As Double
Dim Day27 As Double
Dim Day28 As Double
Dim Day29 As Double
Dim Day30 As Double
Dim Day31 As Double
Dim day As Double
Dim auditor As String
Dim area As String
Dim passorfail As String
day = Sheets("5S Audit").Range("c10").Value
auditor = Sheets("5S Audit").Range("f10").Value
area = Sheets("5S Audit").Range("j10").Value
passorfail = Sheets("5S Audit").Range("p5").Value
'Aisle LOC
Loc1 = Sheets("Feb Aisle Score").Range("B4").Value
Loc2 = Sheets("Feb Aisle Score").Range("B5").Value
Loc3 = Sheets("Feb Aisle Score").Range("B6").Value
Loc4 = Sheets("Feb Aisle Score").Range("B7").Value
Loc5 = Sheets("Feb Aisle Score").Range("B8").Value
Loc6 = Sheets("Feb Aisle Score").Range("B9").Value
Loc7 = Sheets("Feb Aisle Score").Range("B10").Value
Loc8 = Sheets("Feb Aisle Score").Range("B11").Value
Loc9 = Sheets("Feb Aisle Score").Range("B12").Value
Loc10 = Sheets("Feb Aisle Score").Range("B13").Value
Loc11 = Sheets("Feb Aisle Score").Range("B14").Value
Loc12 = Sheets("Feb Aisle Score").Range("B15").Value
Loc13 = Sheets("Feb Aisle Score").Range("B16").Value
Loc14 = Sheets("Feb Aisle Score").Range("B17").Value
Loc15 = Sheets("Feb Aisle Score").Range("B18").Value
Loc16 = Sheets("Feb Aisle Score").Range("B19").Value
Loc17 = Sheets("Feb Aisle Score").Range("B20").Value
Loc18 = Sheets("Feb Aisle Score").Range("B21").Value
Loc19 = Sheets("Feb Aisle Score").Range("B22").Value
Loc20 = Sheets("Feb Aisle Score").Range("B23").Value
Loc21 = Sheets("Feb Aisle Score").Range("B24").Value
Loc22 = Sheets("Feb Aisle Score").Range("B25").Value
Loc23 = Sheets("Feb Aisle Score").Range("B26").Value
Loc24 = Sheets("Feb Aisle Score").Range("B27").Value
Loc25 = Sheets("Feb Aisle Score").Range("B28").Value
Loc26 = Sheets("Feb Aisle Score").Range("B29").Value
Loc27 = Sheets("Feb Aisle Score").Range("B30").Value
Loc28 = Sheets("Feb Aisle Score").Range("B31").Value
Loc29 = Sheets("Feb Aisle Score").Range("B32").Value
Loc30 = Sheets("Feb Aisle Score").Range("B33").Value
Loc31 = Sheets("Feb Aisle Score").Range("B34").Value
Loc32 = Sheets("Feb Aisle Score").Range("B35").Value
Loc33 = Sheets("Feb Aisle Score").Range("B36").Value
Loc34 = Sheets("Feb Aisle Score").Range("B37").Value
Loc35 = Sheets("Feb Aisle Score").Range("B38").Value
Loc36 = Sheets("Feb Aisle Score").Range("B39").Value
'Days
Day1 = Sheets("Feb Aisle Score").Range("C3").Value
Day2 = Sheets("Feb Aisle Score").Range("D3").Value
Day3 = Sheets("Feb Aisle Score").Range("E3").Value
Day4 = Sheets("Feb Aisle Score").Range("F3").Value
Day5 = Sheets("Feb Aisle Score").Range("G3").Value
Day6 = Sheets("Feb Aisle Score").Range("H3").Value
Day7 = Sheets("Feb Aisle Score").Range("I3").Value
Day8 = Sheets("Feb Aisle Score").Range("J3").Value
Day9 = Sheets("Feb Aisle Score").Range("K3").Value
Day10 = Sheets("Feb Aisle Score").Range("L3").Value
Day11 = Sheets("Feb Aisle Score").Range("M3").Value
Day12 = Sheets("Feb Aisle Score").Range("N3").Value
Day13 = Sheets("Feb Aisle Score").Range("O3").Value
Day14 = Sheets("Feb Aisle Score").Range("P3").Value
Day15 = Sheets("Feb Aisle Score").Range("Q3").Value
Day16 = Sheets("Feb Aisle Score").Range("R3").Value
Day17 = Sheets("Feb Aisle Score").Range("S3").Value
Day18 = Sheets("Feb Aisle Score").Range("T3").Value
Day19 = Sheets("Feb Aisle Score").Range("U3").Value
Day20 = Sheets("Feb Aisle Score").Range("V3").Value
Day21 = Sheets("Feb Aisle Score").Range("W3").Value
Day22 = Sheets("Feb Aisle Score").Range("X3").Value
Day23 = Sheets("Feb Aisle Score").Range("Y3").Value
Day24 = Sheets("Feb Aisle Score").Range("Z3").Value
Day25 = Sheets("Feb Aisle Score").Range("AA3").Value
Day26 = Sheets("Feb Aisle Score").Range("AB3").Value
Day27 = Sheets("Feb Aisle Score").Range("AC3").Value
Day28 = Sheets("Feb Aisle Score").Range("AD3").Value
Day29 = Sheets("Feb Aisle Score").Range("AE3").Value
Day30 = Sheets("Feb Aisle Score").Range("AF3").Value
Day31 = Sheets("Feb Aisle Score").Range("AG3").Value
End Sub
我们将不胜感激。
Dim mydate As String, myaisle As String, myscore As Integer
Dim i As Long
Dim coord1 As Integer, coord2 As Integer
mydate = Worksheets("5s Audit").Range("C10").Value
myaisle = Worksheets("5s Audit").Range("F10").Value
myscore = Worksheets("Score Transfer").Range("C1").Value
For i = 4 To 39
If Worksheets("Score Transfer").Cells(i, 1).Value = myaisle Then
coord1 = i
End If
Next i
For i = 2 To 32
If Worksheets("Score Transfer").Cells(3, i).Value = mydate Then
coord2 = i
End If
Next i
Worksheets("Score Transfer").Cells(coord1, coord2).Value = myscore
【问题讨论】:
-
嗨,Erick - 听起来您已经开始尝试自己编写一些东西了。您能否包括该代码 sn-p (在您的问题结束之前?)。有总比没有好。
-
谢谢 dwirony,我已经添加了我开始使用的代码 sn-p。
标签: vba excel multidimensional-array