我正在编写一个VBA代码,其中我输入了以下格式的日期: YYYY-MM.。然后,我希望在excel工作表中找到具有此特定值的单元格,并从同一列中的另一个工作簿中复制数据。
例如,如果我输入"2019-04",我想要找到具有该值的单元格,并使用该日期特定文件中的数据填充该单元格下面的列。
我尝试过使用for循环来做这件事,但是一直做不到。
发布于 2019-06-20 00:09:39
这样如何:
iter = 1
a = ActiveWorkbook.Name
YourValues & iter = Workbooks(b).Cells(xxxx) 'Whatever the second workbook reference is and use a do loop to add more 'iter' values
Workbooks(a).Activate
Cells.Find(What:="2019-04", After:=ActiveCell, LookIn:=xlFormulas,LookAt:=xlPark, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase = False, SearchFormat:=False).Activate
n = 1 'or 2 or however far down below the value you want to place the new data
x = ActiveCell.Column
y = ActiveCell.Row
cells(y + n, x) = YourValues(tier)然后可能是循环中的n+1、iter+1。
https://stackoverflow.com/questions/56671768
复制相似问题