【发布时间】:2016-04-19 20:07:03
【问题描述】:
我遇到了一个用于将信息从一个工作表拉到另一个工作表的宏问题。我无法弄清楚如何让宏查看“CurrentSchedule”工作簿中的不同工作表。当我使用第一张(A 行)工作表浏览宏时,一切运行顺利,但是当我尝试通过第二张(B 行)运行它时,它会超时。它特别卡在这条线上
" Order = Range("W1").Offset(Count, 0).Value"
SAPorder = InputBox("Enter SAP Order Number:")
ProdLine = InputBox("Enter the sheet# of CurrentSchedule that has this SAP order number. Example: A line = 1; B = 2")
End Select
Count = 0 'Count is the row in the designated column
Flag = True
Do While Flag
Workbooks("CurrentSchedule.xlsx").Worksheets(ProdLine).Activate
Order = Range("W1").Offset(Count, 0).Value
If Order = SAPorder Then
nme = Range("B1").Offset(Count, 0).Value
【问题讨论】:
-
您没有任何资格。换句话说,计算机如何知道您想要哪个工作簿/工作表?
-
你只显示了循环的一部分
-
你搜索了什么?这是一个very common 问题。但是,是的,您绝对需要对所有范围进行限定......并包含所有代码。
-
@BruceWayne 这非常很常见,即使你only look at stack overflow
-
@macroman - 哦,毫无疑问!