如何将输入箱输入到单元格中?

发布于 2025-02-09 15:12:06 字数 1443 浏览 0 评论 0原文

我有一个输入箱,用户将在本月以前三个字符 +销售的格式(例如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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忘羡 2025-02-16 15:12:06

只需使用此方法 - 引用ActiveCell时不需要范围()即可。

ActiveCell = Application.InputBox("Enter the Latest Month with Actual Sales Data")

Just use this method - no Range() needed when referencing activecell.

ActiveCell = Application.InputBox("Enter the Latest Month with Actual Sales Data")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文