I have a range of data that has 5 columns P:T, (Asset No, Part No, Lot No, 
Date/time stamp and User ID) and up to 3000 rows, for now. I have Command 
Button with code that works fine for retrieving all rows that have a 
specified asset numbers (Input cell C5).

I just want to include Buttons with the same code but modified for reviving 
Part number and Lot number criteria, each having its own input cell (E5, 
and G5) using their own command button.
Here is the good code for Asset number search/retrieval:
 Private Sub CommandButton1_Click() 
Dim ws1 As Worksheet, ws2 As Worksheet 
Dim rg As Range, c As Range 
Dim sAsset As String, sFrom As String, sEnd As String 
 
Application.ScreenUpdating = False 
Set ws2 = Sheets("QC Raw Material") 
Set ws1 = Sheets("QCRM Usage") 
Set rg = ws2.Range("P5:P3000") 'range with data 
sAsset = ws2.Range("C5") 'asset no 
sFrom = ws2.Range("C28") 'date from 
sEnd = ws2.Range("G28") 'date end 
For Each c In rg 
If c.Value = sAsset Then 
If c.Offset(0, 4) > sFrom And c.Offset(0, 4) < sEnd Then 
c.Resize(1, 5).Copy ws1.Range("A60000").End(xlUp).Offset(1, 0) 'copy to ws1 
End If 
End If 
Next c 
Application.ScreenUpdating = True 
End Sub 
 

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to