ADRIANA P
asked on
need help to look for
column e gave the data to look for LOCATION 7
NEED CREATE PREVIEW WITH SET OF OCURRENCES
HERE THE FILE
DATA2.xlsx
NEED CREATE PREVIEW WITH SET OF OCURRENCES
HERE THE FILE
DATA2.xlsx
what do you need to copy to preview
ASKER
ASKER
every 13 rows is an set
ASKER
the numbers i pull in column E is in location 7 of one set
I need to call the set that corresponds the pull number
I need to call the set that corresponds the pull number
ASKER
nee all the ocurrenes of the pull number
the pull i need the exact numbers call all
for example if i pull 61 i need all numbers with 61
the pull i need the exact numbers call all
for example if i pull 61 i need all numbers with 61
Hi Adriana. First of all the data in your worksheet is not "clean". Quite a lot of your "numbers" are formatted as text or have a space before them.
I removed the blank columns, named the top left cell "cLocation" and ran the following code to remove text values in your third column.
Then I created an autofilter for the data, and code that will copy the results of any filter to the Preview sheet.
Clicking the button in the Dat sheet will trigger this code.
Note that the code I wrote assumes only a very simply filter. Namely filtering by a single number in each column. The code will crash if you use a more complex filter at the moment.
Hope this helps
DATA2.xlsm
I removed the blank columns, named the top left cell "cLocation" and ran the following code to remove text values in your third column.
Sub Cleandata()
Dim rSource As Range, rDest As Range
Dim iRow As Long, iCol As Long
Set rSource = [cLocation].CurrentRegion
For iRow = 1 To rSource.Rows.Count
For iCol = 1 To rSource.Columns.Count
If Not (IsError(rSource(iRow, iCol))) Then
If (IsNumeric(rSource(iRow, iCol))) And (rSource(iRow, iCol) <> "") Then
rSource(iRow, iCol) = CDbl(rSource(iRow, iCol))
Else
Debug.Print rSource(iRow, iCol).Address
End If
End If
Next
Next
End Sub
Then I created an autofilter for the data, and code that will copy the results of any filter to the Preview sheet.
Sub CopyChosen()
Dim ws As Worksheet
Dim rSource As Range, rDest As Range
Dim i As Long, j As Long, iChoice As Long
Dim aF(1 To 3) As Variant
Dim match As Boolean
Set ws = ActiveSheet
Set rSource = [cLocation].CurrentRegion
If ws.AutoFilterMode = False Then
MsgBox ("Please filter the list before copying")
rSource.AutoFilter
Exit Sub
End If
With ws.AutoFilter
For i = 1 To 3
If .Filters(i).On Then aF(i) = CDbl(Replace(.Filters(i).Criteria1, "=", "")) Else aF(i) = Null
Next
End With
Worksheets("PREVIEW").Cells.ClearContents
Set rDest = Worksheets("PREVIEW").Cells(1, 1).Resize(1, 3)
For i = 2 To rSource.Rows.Count
match = True
'match all live filters
For j = 1 To 3
If Not IsNull(aF(j)) Then
If rSource(i, j) <> aF(j) Then
match = False
Exit For
End If
End If
Next
'copy if match
If match Then
For j = 1 To 3
rDest(1, j) = rSource(i, j)
Next
Set rDest = rDest.Offset(1, 0)
End If
Next
End Sub
Clicking the button in the Dat sheet will trigger this code.
Note that the code I wrote assumes only a very simply filter. Namely filtering by a single number in each column. The code will crash if you use a more complex filter at the moment.
Hope this helps
DATA2.xlsm
ASKER
Neil Fleming Good Friend ! thanks for you help !!
but that don't work for me !!
but that don't work for me !!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Martin !
Tha'ts what Im talking about !!
Tha'ts what Im talking about !!
check out this code included in this file just press the button Find Location and introduce your number.
gowflow
DATA2-V01.xlsm
Option Explicit
Sub FindLocation()
Dim WS As Worksheet
Dim WSP As Worksheet
Dim MinRow As Long, MaxRow As Long, I As Long, iRow As Long, cCol As Long
Dim cCell As Range
Dim vComb As Variant
Dim sFind As String, A As String, B As String, C As String
Dim lCount As Integer
Dim FirstAddress As String
Dim sMsg As String
'---> Disable Events
With Application
.EnableEvents = False
'.ScreenUpdating = False
.DisplayAlerts = False
End With
'---> Set Variables
Set WS = ActiveSheet
MinRow = WS.Range("G2").End(xlDown).Row - 1
MaxRow = WS.Range("G" & WS.Rows.Count).End(xlUp).Row
Set WSP = Sheets("PREVIEW")
'---> Clear Preview
WSP.Range("3:" & WS.Rows.Count).EntireRow.ClearContents
cCol = 2
'---> Get input
Do
sFind = InputBox("Please Input a number to look for", "Input Number")
Loop Until (IsNumeric(sFind)) Or sFind = ""
If sFind = "" Then
MsgBox "Search canceled by user", vbInformation, "Find Numbers"
Exit Sub
End If
'---> Get Permutation of the number Found
'A = Left(sFind, 1)
'B = Mid(sFind, 2, 1)
'C = Right(sFind, 1)
'vComb = Array(A & B & C, A & C & B, B & A & C, B & C & A, C & A & B, C & B & A)
vComb = Array(sFind)
For I = LBound(vComb) To UBound(vComb)
With WS.Range("E:E")
FirstAddress = ""
Set cCell = .Find(what:=vComb(I), LookIn:=xlValues, lookat:=xlWhole)
If Not cCell Is Nothing Then
FirstAddress = cCell.Address
Do
'---> check if Item found fall in the correct batch
iRow = cCell.Row
'If iRow Mod 13 = MinRow Then
If iRow Mod 13 = 0 Then
WS.Activate
cCell.Select
'MsgBox "Found " & vComb(I) & " at row " & iRow, vbExclamation, "Find Number"
If sMsg <> "" Then sMsg = sMsg & Chr(10)
sMsg = sMsg & "Found " & vComb(I) & " at row " & iRow
lCount = lCount + 1
'---> Copy Data to Preview
WS.Range(WS.Range("C" & iRow).Offset(-6, 0), WS.Range("G" & iRow - 3 + 12 * 4)).Copy
WSP.Range(WSP.Cells(3, cCol), WSP.Cells(3, cCol)).PasteSpecial xlPasteValues
cCol = cCol + 7
Else
MsgBox "Found " & vComb(I) & " at row " & iRow & " But found after a multiple of " & iRow Mod 13 & " Rows not 13 !!! then this combination not taaken.", vbExclamation, "Find Number"
End If
Set cCell = .FindNext(cCell)
Loop While Not cCell Is Nothing And cCell.Address <> FirstAddress
End If
End With
Next I
WSP.Activate
WSP.Cells(1, 1).Select
WS.Activate
WS.Cells(1, 1).Select
'---> Enable Events
With Application
.EnableEvents = True
'.ScreenUpdating = True
.DisplayAlerts = True
End With
If lCount = 0 Then
MsgBox "No occurence found for Number " & sFind & " and all its combination digits", vbExclamation, "Find Number"
Else
MsgBox "A total of " & lCount & " occurences were found for Number " & sFind & " at " & Chr(10) & sMsg, vbExclamation, "Find Number"
End If
End Sub
gowflow
DATA2-V01.xlsm
ASKER
gowflow THANKS!
GETTING VERY CLOSED TO
GETTING VERY CLOSED TO
Tha'ts what Im talking about !!So does anything need to be changed?
what do you mean ? please clarify
gowflow
gowflow
ASKER
Working as needed Martin !!
ASKER
Gentlemen, they are all great experts.
I am selecting the solution that is currently
Complying with my solution
Thanks to all!!
gowflow Neil Fleming Martin
I am selecting the solution that is currently
Complying with my solution
Thanks to all!!
gowflow Neil Fleming Martin
ASKER
Great ! Solution !!