2 Questions ?

  • Thread starter Thread starter Michael168
  • Start date Start date
M

Michael168

Question 1

How to copy every 2 lines of data to a new sheet when the conditions
meet. i.e. from sheet1 to sheet2.
Sheet 1 holds the overall data and Sheet 2 will contains the filtered
data only.
The conditions are when cell value col2=5 and col38=178 in Sheet 1,the
current row and the row below will be copy to Sheet 2. This will loop
through Sheet 1 from top down.

Question 2
How to delete all worksheets through VBA starting with name like
Order1,Order2, .......until Order150 in one go, keeping only
MasterOrder Sheet in the workbook. It is very tedious to delete
manually.

Thanks & Regards
 
Question 2

drag the master sheet to be either the first sheet or the last sheet.
Click on Order1 sheet tab. Hold down the shift key and click on Order50
sheet tab

Do Edit=>Delete Sheet.

question 1

Dim rng as Range, cell as Range
With Worksheets("Sheet1")
Set rng = .Range(.cells(2,1),.cells(rows.count,1).End(xlup)(0))
End With
for each cell in rng
if cell.offset(0,1)=5 and cell.offset(0,37)=178 then
cell.resize(2,1).EntireRow.Copy Destination:= _
Worksheets("Sheet2").Cells(rows.count,1).End(xlup)(2)
end if
Next

Assumes that the second row copied will not meet the condition.
 
Back
Top