如何使用Cells(x,y)或range(cells)将值从一个单元格输入到另一个?

时间:2019-07-14 23:40:41

标签: excel vba

单元格SecondSetCellInputtedNameCTR(“丰田凯美瑞”),SecondSetCellInputtedLengthCTR(“ 10” /整数)和SecondSetCellInputtedStartDateCTR(“ 2020-04”)中的值分别放置在单元格SecondSetOutputNameCTR,SecondSetCelloutputLengthCTR和SecondSetCelloutputStartDateCate中。

我得到的输出单元格为空,即使代码另有说明。 enter image description here

我已经尝试过:

1)

SecondSetCellInputtedNameCTR = Cells(SecondSetInputtedRowNumCTR, SecondSetInputtedColNumName).Value 'only thing that will change is the CTR which is row entry
SecondSetCellInputtedStartDateCTR = Cells(SecondSetInputtedRowNumCTR, SecondSetInputtedColStartDate).Value 'only thing that will change is the CTR which is row entry
SecondSetCellInputtedLengthCTR = Cells(SecondSetInputtedRowNumCTR, SecondSetInputtedColLength).Value 'only thing that will change is the CTR which is row entry
SecondSetOutputNameCTR = Cells(SecondSetOutputRowNumCTR, CellOutputNameCol)
SecondSetCelloutputLengthCTR = Cells(SecondSetOutputRowNumCTR, CellOutputLengthCol)
SecondSetCelloutputStartDateCTR = Cells(SecondSetOutputRowNumCTR, CellOutputStartDateCol)

2)注意.value是如何被带走的:

SecondSetCellInputtedNameCTR = Cells(SecondSetInputtedRowNumCTR, SecondSetInputtedColNumName) 'only thing that will change is the CTR which is row entry
SecondSetCellInputtedStartDateCTR = Cells(SecondSetInputtedRowNumCTR, SecondSetInputtedColStartDate) 'only thing that will change is the CTR which is row entry
SecondSetCellInputtedLengthCTR = Cells(SecondSetInputtedRowNumCTR, SecondSetInputtedColLength) 'only thing that will change is the CTR which is row entry
SecondSetOutputNameCTR = Cells(SecondSetOutputRowNumCTR, CellOutputNameCol)
SecondSetCelloutputLengthCTR = Cells(SecondSetOutputRowNumCTR, CellOutputLengthCol)
SecondSetCelloutputStartDateCTR = Cells(SecondSetOutputRowNumCTR, CellOutputStartDateCol)`    

在上一节中,我显示了这些术语中的每一个等于什么。

SecondSetInputtedRowNumCTR是从E列的第二个数据集中查看的行号。

Do While SecondSetInputtedRowNumCTR < LengthSecondSet + 1
    SecondSetOutputNameCTR = SecondSetCellInputtedNameCTR
    SecondSetCelloutputLengthCTR = SecondSetCellInputtedLengthCTR
    SecondSetCelloutputStartDateCTR = SecondSetCellInputtedStartDateCTR
    SecondSetInputtedRowNumCTR = SecondSetInputtedRowNumCTR + 1
Loop

我希望得到:
SecondSetOutputNameCTR cell成为“丰田凯美瑞”
SecondSetCelloutputLengthCTR单元格为“ 10”,并且
SecondSetCellInputtedStartDateCTR单元格为“ 2020-04”

我实际上得到了:所有输出单元格的空值。

那是为什么?

0 个答案:

没有答案