PDA

View Full Version : Solved: ActiveWorkbook.Activesheet



YellowLabPro
05-26-2007, 09:24 AM
Because my workbook and worksheet names are different on every occassion, I wanted to go the route of

Set Wss = ActiveWorkbook.ActiveSheet
but me code breaks here:
If Wss.Range(i, 7) = "x" Then


Set Wss = ActiveWorkbook.ActiveSheet
Set Wst = Workbooks("Master PO.xls").Worksheets("FF")
LRow = Wss.Cells(Rows.Count, 1).End(xlUp).Row
For i = 12 To LRow
If Wss.Range(i, 7) = "x" Then
Wst.Cells(i, 3).Value = Wss.Cells(i, 7).Value
Wst.Cells(i, 4).Value = Wss.Cells(i, 2).Value
End If
Next i


Any ideas please?

thanks,

doug

Bob Phillips
05-26-2007, 09:40 AM
It's nothing to do with Wss YLP, it is Range. Range arguments are cells, not row and column nuumbers, that applies to the CElls property.

You either need



If Wss.Range("G" & i).Value = "x" Then


or



If Wss.Cells(i, 7).Value = "x" Then

Bob Phillips
05-26-2007, 09:41 AM
Just seen the rest of the code, you got it right there :)

YellowLabPro
05-26-2007, 06:46 PM
Thanks Bob.