Hi,
I have been working on this VBA and I cannot get it to work.
The aim of this is to move information onto 3 different excel sheets based on conditions. So, If column "A" States Whiston manu OR Whiston Laser OR Whiston Turning AND Column "B" states Yes AND Colunm "L" States Yes it will copy it's self onto a Whiston Manu sheet.
The same applies for the UK Manu sheet and the Non-UK Manu Sheet, but both have different column A words as you can see in the VBA.
I have no idea where I am going wrong, any help or even a new VBA would be very much appreciated. This is what I have so far
Sub Button7_Click()
lastRow = Worksheets("BOM").Range("A" & Rows.Count).End(xlUp).Row
For r = 10 To lastRow
If Worksheets("BOM").Range("A" & r).Value = "WHISTON MANU" Or Worksheets("BOM").Range("A" & r).Value = "WHISTON LASER" Or Worksheets("BOM").Range("A" & r).Value = "WHISTON TURNING" And _
Worksheets("BOM").Range("B" & r).Value = "YES" And _
Worksheets("BOM").Range("L" & r).Value = "YES" Then
Worksheets("BOM").Range("A" & r & ",D" & r & ",E" & r & ",F" & r & ",G" & r & ",J" & r).Copy
Worksheets("WHISTON MANU").Activate
lastRowRpt = Worksheets("WHISTON MANU").Range("A" & Rows.Count).End(xlUp).Row
Worksheets("WHISTON MANU").Range("A" & lastRowRpt + 1).Select
ActiveSheet.Paste
Else
If (Worksheets("BOM").Range("A" & r).Value = "UK MANU" Or Worksheets("BOM").Range("A" & r).Value = "UK LASER" Or Worksheets("BOM").Range("A" & r).Value = "UK TURNING") And _
Worksheets("BOM").Range("B" & r).Value = "YES" And _
Worksheets("BOM").Range("L" & r).Value = "YES" Then
Worksheets("BOM").Range("A" & r & ",D" & r & ",E" & r & ",F" & r & ",G" & r & ",J" & r).Copy
Worksheets("UK MANU").Activate
lastRowRpt = Worksheets("UK MANU").Range("A" & Rows.Count).End(xlUp).Row
Worksheets("UK MANU").Range("A" & lastRowRpt + 1).Select
ActiveSheet.Paste
Else
If Worksheets("BOM").Range("A" & r).Value = "NON-UK MANU" And _
Worksheets("BOM").Range("B" & r).Value = "YES" And _
Worksheets("BOM").Range("L" & r).Value = "YES" Then
Worksheets("BOM").Range("A" & r & ",D" & r & ",E" & r & ",F" & r & ",G" & r & ",J" & r).Copy
Worksheets("NON-UK MANU").Activate
lastRowRpt = Worksheets("NON-UK MANU").Range("A" & Rows.Count).End(xlUp).Row
Worksheets("NON-UK MANU").Range("A" & lastRowRpt + 1).Select
ActiveSheet.Paste
End If
End If
End If
Next r
End Sub
I have been working on this VBA and I cannot get it to work.
The aim of this is to move information onto 3 different excel sheets based on conditions. So, If column "A" States Whiston manu OR Whiston Laser OR Whiston Turning AND Column "B" states Yes AND Colunm "L" States Yes it will copy it's self onto a Whiston Manu sheet.
The same applies for the UK Manu sheet and the Non-UK Manu Sheet, but both have different column A words as you can see in the VBA.
I have no idea where I am going wrong, any help or even a new VBA would be very much appreciated. This is what I have so far
Sub Button7_Click()
lastRow = Worksheets("BOM").Range("A" & Rows.Count).End(xlUp).Row
For r = 10 To lastRow
If Worksheets("BOM").Range("A" & r).Value = "WHISTON MANU" Or Worksheets("BOM").Range("A" & r).Value = "WHISTON LASER" Or Worksheets("BOM").Range("A" & r).Value = "WHISTON TURNING" And _
Worksheets("BOM").Range("B" & r).Value = "YES" And _
Worksheets("BOM").Range("L" & r).Value = "YES" Then
Worksheets("BOM").Range("A" & r & ",D" & r & ",E" & r & ",F" & r & ",G" & r & ",J" & r).Copy
Worksheets("WHISTON MANU").Activate
lastRowRpt = Worksheets("WHISTON MANU").Range("A" & Rows.Count).End(xlUp).Row
Worksheets("WHISTON MANU").Range("A" & lastRowRpt + 1).Select
ActiveSheet.Paste
Else
If (Worksheets("BOM").Range("A" & r).Value = "UK MANU" Or Worksheets("BOM").Range("A" & r).Value = "UK LASER" Or Worksheets("BOM").Range("A" & r).Value = "UK TURNING") And _
Worksheets("BOM").Range("B" & r).Value = "YES" And _
Worksheets("BOM").Range("L" & r).Value = "YES" Then
Worksheets("BOM").Range("A" & r & ",D" & r & ",E" & r & ",F" & r & ",G" & r & ",J" & r).Copy
Worksheets("UK MANU").Activate
lastRowRpt = Worksheets("UK MANU").Range("A" & Rows.Count).End(xlUp).Row
Worksheets("UK MANU").Range("A" & lastRowRpt + 1).Select
ActiveSheet.Paste
Else
If Worksheets("BOM").Range("A" & r).Value = "NON-UK MANU" And _
Worksheets("BOM").Range("B" & r).Value = "YES" And _
Worksheets("BOM").Range("L" & r).Value = "YES" Then
Worksheets("BOM").Range("A" & r & ",D" & r & ",E" & r & ",F" & r & ",G" & r & ",J" & r).Copy
Worksheets("NON-UK MANU").Activate
lastRowRpt = Worksheets("NON-UK MANU").Range("A" & Rows.Count).End(xlUp).Row
Worksheets("NON-UK MANU").Range("A" & lastRowRpt + 1).Select
ActiveSheet.Paste
End If
End If
End If
Next r
End Sub