Avatar of Mike Orther
Mike Orther
Flag for United States of America asked on

Excel Report will not copy results

I have a button on my "Inventory" worksheet that copies items that have "On-Hand" quantity for the number I select.  It pastes the results into the OHReport worksheet.  Everything works just as I want.  

The problem I am having is when I create the same button on the "OHReport" worksheet and run it, I am prompted to enter a quantity, but no results are returned.

Private Sub SelectQtyOH_Click()

Dim OH As String
Dim x As Long
x = 2

OH = InputBox("Enter Search Quantity")
Do While Cells(x, 1) <> ""
If Cells(x, 7) = OH Then
erow = Sheets("OHReport").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Paste Destination:=Worksheets("OHReport").Rows(erow)
End If
x = x + 1
Application.CutCopyMode = False


End Sub

Open in new window

VBAMicrosoft ExcelVisual Basic ClassicMicrosoft Office

Avatar of undefined
Last Comment
Subodh Tiwari (Neeraj)

8/22/2022 - Mon
Subodh Tiwari (Neeraj)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Mike Orther

Yes, this works much better that my code.  The report is much faster.
Mike Orther

Thank you so much for this Subodh.  This works beautifully and it is so much faster than what I had
Subodh Tiwari (Neeraj)

You're welcome Mike! Glad it worked as desired.
Thanks for the feedback.
Merry Christmas!
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck