Home > Software design >  How do I put user's input from inputbox into a cell [VBA]
How do I put user's input from inputbox into a cell [VBA]

Time:06-23

I don't think my title is clear enough, so I'll try my best to explain what I need to do.

I have an input box where the user will type in current month in the format of first three characters Sale (i.e. JunSale). I want to return this user's input into a specific cell. This specific cell already has stuff in it (i.e. MaySale). So once a user types in the input, the cell will now read JunSale not MaySale.

I'm very new to vba, so please excuse my code being really messy and having functions that people recommend avoiding.

Below is my code and it gives me an error message that reads: Compile Error: Method or data member not found with highlight on the very last line of the code.

How should I fix this code? I've been fighting with it for 3 hours and have made no progress :'(

Any help is appreciated thank you!!!!

Edit:

This is the code I have now and 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")

CodePudding user response:

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

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