Ahhh... <d'oh> I always miss that off...
Hmmm. Ok it's assigned the used range to the required object now, but I'm having problems with the next bit - I need to check the first character in the first row (column headings), and if it's not W or S I need to delete the column.
Here's my revised code that should do that, but it's not:
'Next, go through the columns in the worksheet...
wTscWorkbook.Activate
Set rngUsed = ActiveWorkbook.Sheets("Sheet1").UsedRange
For Each i In rngUsed.Columns
If Left(wTscWorkbook.Sheets("Sheet1").Cells(1, i), 1) <> "W" And Left(wTscWorkbook.Sheets("Sheet1").Cells(1, i), 1) <> "S" Then
'The column is not a weekly figure. Delete it.
wTscWorkbook.Sheets("Sheet1").Columns(i).Delete
i = i - 1
End If
Next i
I've dim'd "i" as a variant as it can't be an integer. Can't get my head around why it errors on the if statement though... any ideas?
Cheers,
Ad