I am very new to VBA and have been teaching myself for the last week. I have taken on a task that is maybe a bit to complex for me.
I have a document with columns A - AE I need to go through this document and move information on to separate sheets, depending on what it is. I am now trying to use an IF statement that needs to match 2 requirements before it moves the information. I can get each individual requirement to work but not both together as keep getting a Type Mismatch error.
I have no idea what i am doing wrong. Any help will be much appreciated.
Sub copyrows()
Dim Test As Range, Cell As Object
Set Test = Range("G2:Z4000") 'Substitute with the range which includes your True/False values
For Each Cell In Test
If IsEmpty(Cell) Then
Exit Sub
End If
If Cell.Value = "Refund" And "Commission" Then
Cell.EntireRow.Copy
Sheet3.Select 'Substitute with your sheet
ActiveSheet.Range("A65536").End(xlUp).Select
Selection.Offset(1, 0).Select
ActiveSheet.Paste
End If
Next
End Sub
CellanObject? I'd make it aRangeinstead, because that's what you're using it as. WhileObjectmay work,Rangeis better I believe.