Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-21-2017, 10:55 PM
trevorc trevorc is offline find and find next across multiple tabs Windows 7 32bit find and find next across multiple tabs Office 2013
Competent Performer
find and find next across multiple tabs
 
Join Date: Jan 2017
Posts: 173
trevorc will become famous soon enoughtrevorc will become famous soon enough
Default find and find next across multiple tabs

Hi All,
Is it possible to use find/find next across multiple tabs looking for the same variable?
Reply With Quote
  #2  
Old 02-22-2017, 10:15 AM
NoSparks NoSparks is offline find and find next across multiple tabs Windows 7 64bit find and find next across multiple tabs Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

Yes

What have you tried?
Reply With Quote
  #3  
Old 02-22-2017, 02:51 PM
trevorc trevorc is offline find and find next across multiple tabs Windows 7 32bit find and find next across multiple tabs Office 2013
Competent Performer
find and find next across multiple tabs
 
Join Date: Jan 2017
Posts: 173
trevorc will become famous soon enoughtrevorc will become famous soon enough
Default

The attached file shows my progress so far, the find component on the instructions sheet works fine but I am having trouble with getting the vba code to work on the check_sheet sheet.

i need to search for a part, if found check for available qty if not enough keep checkinf for other locations in same sheet and other sheets, if still not enough add to list of purchases requied, otherwise add to list of in stock. I am trying to modify the code from the find part vba that does work for one part. trying one thing at a time, it still adds an extra line for when we don't have enough, into the list of have enough.

see attached file for sample, currently using various sample data for testing.
Component List and Locations .xlsm

Code:
 
Sub Macro6()
    Dim ws As Worksheet
    Dim lLastRow As Long, lLastColumn As Long
    Dim lRealLastRow As Long, lRealLastColumn As Long
    'first get sheet data and put it into the check sheet
    Worksheets("check_sheet").Range("A17:Z1000").Delete
    With Range("A1").SpecialCells(xlCellTypeLastCell)
        lLastRow = .Row
        lLastColumn = .Column
    End With
    lRealLastRow = Cells.Find("*", Range("A1"), xlFormulas, , xlByRows, xlPrevious).Row
    lRealLastColumn = Cells.Find("*", Range("A1"), xlFormulas, , xlByColumns, xlPrevious).Column
    If lRealLastRow < lLastRow Then
        Range(Cells(lRealLastRow + 1, 1), Cells(lLastRow, 1)).EntireRow.Delete
    End If
    If lRealLastColumn < lLastColumn Then
        Range(Cells(1, lRealLastColumn + 1), Cells(1, lLastColumn)).EntireColumn.Delete
    End If
    ActiveSheet.UsedRange    'Resets LastCell
    Number_of_parts = 10    'InputBox("Enter the number of units required")
    Part_Col = "E"    'InputBox("Enter the Column of the Part Number to check")
    qty_col = "CP"    'InputBox("Enter the Column to check for the required Quantity")
    Start_Row = 3    'InputBox("Enter the number of the First Row to check")
    ttttt = 0
    
    Sheets("Check_Sheet").Select
    str_rng = Part_Col & Start_Row
    Last_Row = ActiveSheet.Range("c3").SpecialCells(xlCellTypeLastCell).Row
    For i = 1 To Last_Row
        If Not IsEmpty(foundNum) Then
            find_it = Range(Part_Col & Start_Row + foundNum)    ' first cell to check
        Else
            find_it = Range(Part_Col & Start_Row).Value    ' first cell to check
        End If
        
        
        For Each ws In ThisWorkbook.Worksheets
            With ws
                If ws.Name = "Manufacturers & Suppliers" Or ws.Name = "Check_Sheet" _
                   Or ws.Name = "Instructions" Or ws.Name = "Storage Locations" _
                   Or ws.Name = "Check Sheet" Or ws.Name = "Output_Required" _
                   Or ws.Name = "Output_Have" Then
                    GoTo Next_ws
                End If
                t = ws.Name
                Set Found = .Range("F3:F10000").Find(What:=find_it, LookIn:=xlValues, LookAt:=xlPart, MatchCase:=False)
                If Not Found Is Nothing Then
                    X = Found.Address
                    y = Found.Row
                    yy = "$" & qty_col & "$" & y
                    ttt = Worksheets("Check_sheet").Range(yy).Value
                    aaa = Worksheets(t).Range("$D$" & y).Value
                    If ttt * Number_of_parts < aaa Then
                        'have_enough, copy to output_have, goto next part
                        FirstAddress = Found.Address
                        If ttttt <> 1 Then foundNum = foundNum + 1
                        AddressStr = .Name & " " & Found.Address & vbCrLf
                        addr = Found.Address
                        Set Found = .Range("F3:F10000").FindNext(Found)
                        r1 = Found.Row
                        Worksheets("check sheet").Range("A1" & foundNum).Value = r1
                        row18 = foundNum + 17
                        Found.EntireRow.Copy Destination:=Worksheets("check_sheet").Range("A" & row18)
                        Worksheets("check_sheet").Range("AA1") = AddressStr
                        Range("AA1").Copy
                        Range("A" & row18).Select
                        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
                        Worksheets("check_sheet").Range("B" & row18) = ttt * Number_of_parts
                    Else
                        'not enough, check for more locations, if not then copy to output_required
                        '  FirstAddress = Found.Address
                        foundNum = foundNum + 1
                        ttttt = 1
                        Worksheets("check sheet").Range("A1:A1000").Delete
                        Worksheets("check sheet").Range("AA1").Delete
                        Worksheets("check_sheet").Range("b" & row18) = ttt * Number_of_parts
                    End If
                End If
            End With
Next_ws:
            Worksheets("check sheet").Range("A1:A1000").Delete
            Worksheets("check sheet").Range("AA1").Delete
        Next ws
        i = i + 1
    Next i
    Worksheets("check sheet").Range("A1:A1000").Delete
    Worksheets("check sheet").Range("AA1").Delete
    If Len(AddressStr) Then
    Else:
        MsgBox "Unable to find " & myText & " in this workbook.", vbExclamation
    End If
    With Range("A1").SpecialCells(xlCellTypeLastCell)
        lLastRow = .Row
        lLastColumn = .Column
    End With
    lRealLastRow = Cells.Find("*", Range("A1"), xlFormulas, , xlByRows, xlPrevious).Row
    lRealLastColumn = Cells.Find("*", Range("A1"), xlFormulas, , xlByColumns, xlPrevious).Column
    If lRealLastRow < lLastRow Then
        Range(Cells(lRealLastRow + 1, 1), Cells(lLastRow, 1)).EntireRow.Delete
    End If
    If lRealLastColumn < lLastColumn Then
        Range(Cells(1, lRealLastColumn + 1), Cells(1, lLastColumn)).EntireColumn.Delete
    End If
    ActiveSheet.UsedRange    'Resets LastCell
    Worksheets("check_sheet").Range("A18").Select
    Worksheets("check_sheet").Range("G5").Select
End Sub
Reply With Quote
  #4  
Old 02-22-2017, 05:36 PM
NoSparks NoSparks is offline find and find next across multiple tabs Windows 7 64bit find and find next across multiple tabs Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

Quote:
I am having trouble with getting the vba code to work on the check_sheet sheet.
Can you elaborate on this ?
Reply With Quote
  #5  
Old 02-22-2017, 06:22 PM
trevorc trevorc is offline find and find next across multiple tabs Windows 7 32bit find and find next across multiple tabs Office 2013
Competent Performer
find and find next across multiple tabs
 
Join Date: Jan 2017
Posts: 173
trevorc will become famous soon enoughtrevorc will become famous soon enough
Default

trying one thing at a time, it still adds an extra line for when we don't have enough, into the list of have enough.

try the sample and see it happen.
Reply With Quote
  #6  
Old 02-22-2017, 07:07 PM
NoSparks NoSparks is offline find and find next across multiple tabs Windows 7 64bit find and find next across multiple tabs Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

Sorry buds, too convoluted for me.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to do multiple find and replace in string. PRA007 Word VBA 2 01-06-2016 09:10 PM
find IP in range / find number between numbers gn28 Excel 4 06-14-2015 03:46 PM
find and find next across multiple tabs Find what box in Find and replace limits the length of a search term Hoxton118 Word VBA 7 06-10-2014 05:05 AM
find and find next across multiple tabs How do I find and replace multiple items at once? redzan Word VBA 1 05-16-2013 08:25 AM
find and find next across multiple tabs Bad view when using Find and Find & Replace - Word places found string on top line paulkaye Word 4 12-06-2011 11:05 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:55 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft