如何将输入箱输入到单元格中?
我有一个输入箱,用户将在本月以前三个字符 +销售的格式(例如Junsale)输入。
我想将其返回到一个特定的单元格中。该单元已经有东西(例如Maysale)。一旦用户键入输入,该单元格现在将读取Junsale而不是Maysale。
我的代码给我一个错误消息:
编译错误:未找到方法或数据成员
编译错误:未在代码的最后一行中
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Sales Calc")
Dim ActSales As Range
Dim pastmthsale As String
Dim currentmthsale As String
With Worksheets("Sales Calc").Cells
Set ActSales = .Find("Forecast Sales -->>", After:=Range("DH173"), LookIn:=xlValues)
If Not ActSales Is Nothing Then
ActSales.Select
End If
End With
ActiveCell.Offset(rowOffset:=0, ColumnOffset:=-1).Select
pastmthsale = Selection.Value
currentmthsale= Application.InputBox("Enter the Latest Month with Actual Sales Data")
ws.pastmthsale = currentmthsale
。这是我现在拥有的代码。我收到的错误消息是
应用程序定义或对象定义的错误。
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Sales Calc")
Dim ActSales As Range
With Worksheets("Sales Calc").Cells
Set ActSales = .Find("Forecast Sales -->>", After:=Range("DH173"), LookIn:=xlValues)
If Not ActSales Is Nothing Then
ActSales.Select
End If
End With
ActiveCell.Offset(rowOffset:=0, ColumnOffset:=-1).Select
Range(ActiveCell) = Application.InputBox("Enter the Latest Month with Actual Sales Data")
I have an InputBox where the user will type in the current month in the format of first three characters + Sale (e.g. JunSale).
I want to return this into a specific cell. This cell already has stuff in it (e.g. MaySale). Once a user types in the input, the cell will now read JunSale not MaySale.
My code gives me an error message:
Compile Error: Method or data member not found
with highlight on the last line of the code.
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Sales Calc")
Dim ActSales As Range
Dim pastmthsale As String
Dim currentmthsale As String
With Worksheets("Sales Calc").Cells
Set ActSales = .Find("Forecast Sales -->>", After:=Range("DH173"), LookIn:=xlValues)
If Not ActSales Is Nothing Then
ActSales.Select
End If
End With
ActiveCell.Offset(rowOffset:=0, ColumnOffset:=-1).Select
pastmthsale = Selection.Value
currentmthsale= Application.InputBox("Enter the Latest Month with Actual Sales Data")
ws.pastmthsale = currentmthsale
This is the code I have now. The error message I get is
Application-defined or object-defined error.
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Sales Calc")
Dim ActSales As Range
With Worksheets("Sales Calc").Cells
Set ActSales = .Find("Forecast Sales -->>", After:=Range("DH173"), LookIn:=xlValues)
If Not ActSales Is Nothing Then
ActSales.Select
End If
End With
ActiveCell.Offset(rowOffset:=0, ColumnOffset:=-1).Select
Range(ActiveCell) = Application.InputBox("Enter the Latest Month with Actual Sales Data")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需使用此方法 - 引用ActiveCell时不需要范围()即可。
Just use this method - no Range() needed when referencing activecell.