Avatar of Mike Orther
Mike OrtherFlag 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")
Sheets("Inventory").Select
Do While Cells(x, 1) <> ""
If Cells(x, 7) = OH Then
Worksheets("Inventory").Rows(x).Copy
Worksheets("OHReport").Activate
erow = Sheets("OHReport").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
ActiveSheet.Paste Destination:=Worksheets("OHReport").Rows(erow)
End If
Worksheets("Inventory").Activate
x = x + 1
Loop
Application.CutCopyMode = False

Sheets("OHReport").Select

End Sub

Open in new window

VBAMicrosoft ExcelVisual Basic ClassicMicrosoft Office

Avatar of undefined
Last Comment
Subodh Tiwari (Neeraj)
ASKER CERTIFIED SOLUTION
Avatar of Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj)
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Mike Orther
Mike Orther
Flag of United States of America image

ASKER

Yes, this works much better that my code.  The report is much faster.
Avatar of Mike Orther
Mike Orther
Flag of United States of America image

ASKER

Thank you so much for this Subodh.  This works beautifully and it is so much faster than what I had
You're welcome Mike! Glad it worked as desired.
Thanks for the feedback.
Merry Christmas!
Visual Basic Classic
Visual Basic Classic

Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.

165K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo