View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bishop Bishop is offline
external usenet poster
 
Posts: 208
Default Activate a Workbook

I see what you're doing when I try that I still get another error. Here's my
code:

For Each wb In Workbooks
'Test to see if wb's name is like "*C&A PF*.xlsm"
If wb.Name Like "*C&A PF*.xlsm" Then
With wb
Set CDLastRow = .Sheets("Catalyst Dump").Range("A" &
Rows.Count) _
& .End(xlUp).Row
.Worksheets("Catalyst Dump").Columns("D").ColumnWidth = 18
End With
End If
Next

I've tried:
Set CDLastRow = but this gives Object Required error
CDLastRow = but this gives RT Error: '438' Object doesn't support property
or method
CDLastRow = .Worksheets still 438

I can't figure it out.

"Joel" wrote:

There is no need to activate the sheets or the workbook. Just use wb instead
of the workbook name


For Each wb In Workbooks
'Test to see if wb's name is like "*C&A PF*.xlsm"
If wb.Name Like "*C&A PF*.xlsm" Then
with wb
.sheets("Sheet1").Range("A1") = "ABC"
end wb
End If
Next


"Bishop" wrote:

I have this code:

For Each wb In Workbooks
'Test to see if wb's name is like "*C&A PF*.xlsm"
If wb.Name Like "*C&A PF*.xlsm" Then
???.Activate
End If
Next

How do I make THAT workbook the active workbook?