PDA

View Full Version : Search for Values that meet a Criteria and Paste Location in a New Sheet



JorgeFlores
10-25-2017, 03:30 AM
Hello Experts!

I have the following Problem that I would like to solve. I have already searched through current threads and have not find a solution and my Knowledge is not enough to even define how I could start.

I have a sheet (attached to this threat) with Solar Panel names and Date with times and I would like to do the following: to search for all values that are less than 2,5 (or less than any other value set as reference to compare) and in a new sheet paste the Name of the Solar Panel and at what times it had this value less than 2,5. This is thought to be done once a month and for more than 1,000 Panels so we can reclaim Warranty to the Panel manufacturer and/or sent technicians to check if Panels are correctly wired. Could someone help me with a VBA Code that could do such?

Thank you very much in advance, having this would done would mean a lot to me and to my chances of staying at the Company, since now I am just a working Student.

Jorge

offthelip
10-25-2017, 07:55 AM
try this:

Sub findpanel()
Dim outarr()
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
lastcol = Cells(1, Columns.Count).End(xlToLeft).Column
inarr = Range(Cells(1, 1), Cells(lastrow, lastcol))
ReDim outarr(1 To lastrow * lastcol, 1 To lastcol)
outarr(1, 1) = "Panel Name"
outarr(1, 2) = "date"


indi = 2
lowlimit = 2.5


For i = 2 To lastrow
For j = 2 To lastcol
If inarr(i, j) <= lowlimit Then
outarr(indi, 1) = inarr(1, j)
outarr(indi, 2) = inarr(i, 1)
indi = indi + 1
End If
Next j
Next i


With Worksheets("Not Working Panels")
Range(.Cells(1, 1), .Cells(lastrow*lastcol, lastcol)) = outarr
End With






End Sub