Hi, over past day or so i've built a quite a like VBA script with the help of the recorder, google and searching this board. However i've now hit a wall.
The script imports an ASCII file, sorts it then analyses the data, couting totals etc. The difficulty comes in the fact the the ASCII file contents can be very varied. So the Macro has to check whether certain things are there then copies them to another sheet.
The problem I'm having is I'm using 'like' function to search as it doesn't seem to crash the script if it doesn't find the word its looking for. However now i need to copy a column only if 2 like functions return a true. The extract of code i'm using to search a row for 1 condition is shown below:
So basically the code looks for a cell containing 'DOG' in row 2 (b-z)then copies the entire column to a new sheet (data). However i only want it to copy it if it also finds a second condition in the same colum it finds 'DOG' eg: CAT. Basically the column should be copied if both the DOG and CAT in the same column is true. If both conditions aren't met it should move on.
Any help would be awesome.
Thanks,
Al
The script imports an ASCII file, sorts it then analyses the data, couting totals etc. The difficulty comes in the fact the the ASCII file contents can be very varied. So the Macro has to check whether certain things are there then copies them to another sheet.
The problem I'm having is I'm using 'like' function to search as it doesn't seem to crash the script if it doesn't find the word its looking for. However now i need to copy a column only if 2 like functions return a true. The extract of code i'm using to search a row for 1 condition is shown below:
Code:
For Each rng1 In Range("b2:z2")
If rng1.Value Like ("*DOG*") Then
rng1.EntireColumn.Copy
Sheets("Data").Select
Columns("c:c").Select
ActiveSheet.Paste
Sheets("Imported Data").Select
End If
Next rng1
Any help would be awesome.
Thanks,
Al