简体   繁体   中英

Using an input how do I copy certain data from a row on one sheet and display it in another sheet

When I try this code an error comes up saying "Run Time Error '424': Object Required" I can see that it finds the inputted number, but doesn't copy any number in the row. It also pastes "0" in the wrong sheet. Here's my code:

Dim x As Integer
Dim a As Integer
Dim b As Integer
x = InputBox(("Input palletizer pattern."), ("Pattern"), (0))
Application.Goto ThisWorkbook.Sheets("Palletizer 2").Range("A:A").Cells(Application.Match(x, ThisWorkbook.Sheets("Palletizer 2").Range("A:A")))
With Selection
ActiveCell.Offset(0, 3) = a
Set ThisWorkbook.Sheets("Palletizer Changeover App").Range("I6") = a
End With

Any help would be much appreciated.

You are getting the error because you use a set statement to assign the integer a to the range I6 . You can only use set statements to assign objects.

The error will go away if you remove the Set in the second last line. However, please note that it would be more obvious what you are trying to achieve if you explicitly assigned to the Value property of the range, which its default property.

With why the number does not appear at the right spot I cannot help you because your exact intentions are not clear to me from your question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM