Thread: Input Box flaw?
View Single Post
  #2   Report Post  
JonathanK1 JonathanK1 is offline
Member
 
Posts: 40
Default

How's this (below)? It opens perfectly in another workbook but when it pulls by the input box (column H/8), it's bringing in rows that shouldn't be there. For example, if I enter 2007 for the year, 50 or so rows will copy over that match my query....but a handful will be from 2006. Isthere a way to keep it from doing that? It's pulling the data I want along with some data I DON'T want and didn't ask for. Strange. If I can't fix this, it's not much good to me.

As always, I appreciate everyone's help.

---

Sub Button6_Click()

Dim TheAnswer As String

Dim working As Worksheet, dumping As Workbook

Set working = ActiveSheet

TheAnswer = LCase$(InputBox("Enter Year below"))

Set dumping = Workbooks.Add

For x = 1 To 17

working.Rows(x).EntireRow.Copy

dumping.Activate

ActiveSheet.Paste

ActiveCell.Offset(1).Select

Next

For x = 1 To working.Cells.SpecialCells(xlCellTypeLastCell).Row

If LCase$(working.Cells(x, 8).Value) = TheAnswer Then

working.Rows(x).EntireRow.Copy

dumping.Activate

ActiveSheet.Paste

ActiveCell.Offset(1).Select

End If

Next

Application.CutCopyMode = False

Cells.Sort Key1 etc. etc.