PDA

View Full Version : Solved: Copy Data that meets criteria



YellowLabPro
05-15-2007, 08:41 AM
My little code here places data from one sheet to another.
I am curious if rather than looping through the sheet after the values have been placed and deleting any records that are zero or blank, if initially the record could be skipped, not imported?
If the qty is equal to zero or blank which is in col. D of Wss then do not import


Sub Eastern()
Dim Wss As Worksheet, Wst As Worksheet
Dim Wbsv As String
Dim LRow As Long
'Wbsv = Application.InputBox("Enter Workbook Name", Type:=2)
'Wssv = Application.InputBox("Enter Worksheet Name", Type:=2)

Set Wss = Workbooks("book1.xls").Worksheets("Sheet1")
Set Wst = Workbooks("TGSItemRecordCreatorMaster.xls") _
.Worksheets("Record Creator")
LRow = Wss.Cells(Rows.Count, 3).End(xlUp).Row
Wst.Range("I6:I" & LRow + 4).Value = Wss.Range("C2:C" & LRow + 4).Value
Wst.Range("Z6:Z" & LRow + 4).Value = Wss.Range("F2:F" & LRow + 4).Value
Wst.Range("AC6:AC" & LRow + 4).Value = Wss.Range("D2:D" & LRow + 4).Value

End Sub
' If item count is = to zero or "" then do not import

Bob Phillips
05-15-2007, 08:45 AM
Create a formula that identifies rows to be deleted, then filter by that coloumn, delete visible rows.

YellowLabPro
05-15-2007, 08:47 AM
Thanks Bob,
I will give that a whirl...

YellowLabPro
05-16-2007, 05:59 AM
Used this method...

On Error Resume Next ' In case there are no blanks
Wss.Columns("H:H").SpecialCells(xlCellTypeBlanks).EntireRow.Delete