Nlhicks
Active Member
- Joined
- Jan 8, 2021
- Messages
- 264
- Office Version
- 365
- Platform
- Windows
Sub FindRightCell()
Dim LineUpdate As Worksheet, Sheet2 As Worksheet
Dim x As Long
Dim y As Range, z As Range
Dim c As Range
Dim resp As VbMsgBoxResult
Dim ans As Variant
Set LineUpdate = Worksheets("Line Update")
Set Sheet2 = Worksheets("Sheet2")
With Sheet2.Range("A1")
If LineUpdate.Range("D5").Value <> "" Then .AutoFilter field:=10, Criteria1:="*" & LineUpdate.Range("D5") & "*"
If LineUpdate.Range("D6").Value <> "" Then .AutoFilter field:=11, Criteria1:="*" & LineUpdate.Range("D6") & "*"
If LineUpdate.Range("D7").Value <> "" Then .AutoFilter field:=12, Criteria1:=LineUpdate.Range("D7")
With Sheet2.UsedRange
For Each y In .Rows
If Application.CountA = 1 Then
Worksheets("Line Update").Range("C11").Value = Worksheets("Sheet2").Range("B:B").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C12").Value = Worksheets("Sheet2").Range("C:C").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C13").Value = Worksheets("Sheet2").Range("D:D").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C14").Value = Worksheets("Sheet2").Range("E:E").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C15").Value = Worksheets("Sheet2").Range("F:F").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C16").Value = Worksheets("Sheet2").Range("G:G").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C17").Value = Worksheets("Sheet2").Range("H:H").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C18").Value = Worksheets("Sheet2").Range("I:I").SpecialCells(xlCellTypeVisible).
GoTo NoTOBus
Exit For
ElseIf Application.CountA <> 1 Then
GoTo TOBus
TOBus:
If LineUpdate.Range("H6").Value <> "" Then .AutoFilter field:=13, Criteria1:=LineUpdate.Range("H6")
Call Item_Open
Worksheets("Line Update").Range("C11").Value = Worksheets("Sheet2").Range("B2:B685").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C12").Value = Worksheets("Sheet2").Range("C2:C685").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C13").Value = Worksheets("Sheet2").Range("D2:D685").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C14").Value = Worksheets("Sheet2").Range("E2:E685").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C15").Value = Worksheets("Sheet2").Range("F2:F685").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C16").Value = Worksheets("Sheet2").Range("G2:G685").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C17").Value = Worksheets("Sheet2").Range("H2:H685").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C18").Value = Worksheets("Sheet2").Range("I2:I685").SpecialCells(xlCellTypeVisible)
Exit For
End If
Next
End With
NoTOBus:
End With
End Sub
Dim LineUpdate As Worksheet, Sheet2 As Worksheet
Dim x As Long
Dim y As Range, z As Range
Dim c As Range
Dim resp As VbMsgBoxResult
Dim ans As Variant
Set LineUpdate = Worksheets("Line Update")
Set Sheet2 = Worksheets("Sheet2")
With Sheet2.Range("A1")
If LineUpdate.Range("D5").Value <> "" Then .AutoFilter field:=10, Criteria1:="*" & LineUpdate.Range("D5") & "*"
If LineUpdate.Range("D6").Value <> "" Then .AutoFilter field:=11, Criteria1:="*" & LineUpdate.Range("D6") & "*"
If LineUpdate.Range("D7").Value <> "" Then .AutoFilter field:=12, Criteria1:=LineUpdate.Range("D7")
With Sheet2.UsedRange
For Each y In .Rows
If Application.CountA = 1 Then
Worksheets("Line Update").Range("C11").Value = Worksheets("Sheet2").Range("B:B").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C12").Value = Worksheets("Sheet2").Range("C:C").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C13").Value = Worksheets("Sheet2").Range("D:D").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C14").Value = Worksheets("Sheet2").Range("E:E").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C15").Value = Worksheets("Sheet2").Range("F:F").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C16").Value = Worksheets("Sheet2").Range("G:G").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C17").Value = Worksheets("Sheet2").Range("H:H").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C18").Value = Worksheets("Sheet2").Range("I:I").SpecialCells(xlCellTypeVisible).
GoTo NoTOBus
Exit For
ElseIf Application.CountA <> 1 Then
GoTo TOBus
TOBus:
If LineUpdate.Range("H6").Value <> "" Then .AutoFilter field:=13, Criteria1:=LineUpdate.Range("H6")
Call Item_Open
Worksheets("Line Update").Range("C11").Value = Worksheets("Sheet2").Range("B2:B685").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C12").Value = Worksheets("Sheet2").Range("C2:C685").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C13").Value = Worksheets("Sheet2").Range("D2:D685").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C14").Value = Worksheets("Sheet2").Range("E2:E685").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C15").Value = Worksheets("Sheet2").Range("F2:F685").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C16").Value = Worksheets("Sheet2").Range("G2:G685").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C17").Value = Worksheets("Sheet2").Range("H2:H685").SpecialCells(xlCellTypeVisible)
Worksheets("Line Update").Range("C18").Value = Worksheets("Sheet2").Range("I2:I685").SpecialCells(xlCellTypeVisible)
Exit For
End If
Next
End With
NoTOBus:
End With
End Sub