Hello Friends,
I am using the below code which works just fine copying data from a worksheet to another
I just want to add 2 criterias after the below compulsory part of the code
COMPULORY PART
For Each cell In rng13
If cell.Value = "In Process" Then
Criteria 1
if cell ("A1").value = 2 then
For Each cell In rng4
If cell.Value like "*Lomotex*" Then
Criteria 2
if cell ("A1").value = 3 then
For Each cell In rng4
If (Not cell.Value Like "*Lomotex*") Then
If range("A1").value is neither 2 nor 3 then the below code to work only with the COMPULSORY PART as it is doing right now
Regards,
Humayun
I am using the below code which works just fine copying data from a worksheet to another
I just want to add 2 criterias after the below compulsory part of the code
COMPULORY PART
For Each cell In rng13
If cell.Value = "In Process" Then
Criteria 1
if cell ("A1").value = 2 then
For Each cell In rng4
If cell.Value like "*Lomotex*" Then
Criteria 2
if cell ("A1").value = 3 then
For Each cell In rng4
If (Not cell.Value Like "*Lomotex*") Then
If range("A1").value is neither 2 nor 3 then the below code to work only with the COMPULSORY PART as it is doing right now
VBA Code:
Sub ro_all()
Set rng1 = Names("orders_po").RefersToRange
Set rng2 = Names("orders_ref").RefersToRange
Set rng3 = Names("orders_po_date").RefersToRange
Set rng4 = Names("orders_customer").RefersToRange
Set rng5 = Names("orders_supplier").RefersToRange
Set rng6 = Names("orders_article").RefersToRange
Set rng7 = Names("orders_quality").RefersToRange
Set rng8 = Names("orders_size").RefersToRange
Set rng9 = Names("orders_quantity").RefersToRange
Set rng10 = Names("orders_unit").RefersToRange
Set rng11 = Names("orders_po_shipment_date").RefersToRange
Set rng12 = Names("orders_remarks").RefersToRange
Set rng13 = Names("orders_status").RefersToRange
destRow = 4
For Each cell In rng13
If cell.Value = "In Process" Then
ActiveSheet.Cells(destRow, 1).Value = rng1.Cells(cell.Row - rng1.Row + 1, 1).Value
ActiveSheet.Cells(destRow, 2).Value = rng2.Cells(cell.Row - rng2.Row + 1, 1).Value
ActiveSheet.Cells(destRow, 3).Value = rng3.Cells(cell.Row - rng3.Row + 1, 1).Value
ActiveSheet.Cells(destRow, 4).Value = rng4.Cells(cell.Row - rng4.Row + 1, 1).Value
ActiveSheet.Cells(destRow, 5).Value = rng5.Cells(cell.Row - rng5.Row + 1, 1).Value
ActiveSheet.Cells(destRow, 6).Value = rng6.Cells(cell.Row - rng6.Row + 1, 1).Value
ActiveSheet.Cells(destRow, 7).Value = rng7.Cells(cell.Row - rng7.Row + 1, 1).Value
ActiveSheet.Cells(destRow, 8).Value = rng8.Cells(cell.Row - rng8.Row + 1, 1).Value
ActiveSheet.Cells(destRow, 9).Value = rng9.Cells(cell.Row - rng9.Row + 1, 1).Value
ActiveSheet.Cells(destRow, 10).Value = rng10.Cells(cell.Row - rng10.Row + 1, 1).Value
ActiveSheet.Cells(destRow, 11).Value = rng11.Cells(cell.Row - rng11.Row + 1, 1).Value
ActiveSheet.Cells(destRow, 13).Value = rng12.Cells(cell.Row - rng12.Row + 1, 1).Value
destRow = destRow + 1 ' Move to the next row in the destination sheet
End If
Next cell
End Sub
Regards,
Humayun