Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default With block does not work on inactive worksheet?

Hi All,

I have these lines inside a function -

Dim ws As Worksheet
Set ws = Sheets(SheetName)
ws.Activate
colCount = ws.UsedRange.Columns.count
With ws.Range(Cells(1, 1), Cells(1, colCount))
Set c = .Find("C", LookIn:=xlValues, LookAt:=xlWhole,
MatchCase:=True)
'.......
End With

Until ws.Activate was added, it jumped out of a function on With statement.
Weird....


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default With block does not work on inactive worksheet?

You have to qualify all objects

With ws.Range(ws.Cells(1, 1), ws.Cells(1, colCount))
Set c = .Find("C", LookIn:=xlValues, LookAt:=xlWhole,
MatchCase:=True)
'.......
End With

--
HTH

Bob Phillips

"Vik" wrote in message
...
Hi All,

I have these lines inside a function -

Dim ws As Worksheet
Set ws = Sheets(SheetName)
ws.Activate
colCount = ws.UsedRange.Columns.count
With ws.Range(Cells(1, 1), Cells(1, colCount))
Set c = .Find("C", LookIn:=xlValues, LookAt:=xlWhole,
MatchCase:=True)
'.......
End With

Until ws.Activate was added, it jumped out of a function on With

statement.
Weird....




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I email an inactive copy of a worksheet Jackaroo 1281 Excel Discussion (Misc queries) 1 January 1st 09 03:36 PM
how to delete the little red arrow in excell work sheet block earledawg Excel Worksheet Functions 1 May 29th 08 02:09 PM
Assign Range - Inactive Worksheet jazzjava Excel Programming 6 June 16th 05 01:39 AM
Can I freeze pane on an inactive worksheet? Mcubitt Excel Programming 1 November 22nd 04 04:46 PM
How to get the activecell of inactive worksheet ? steven[_2_] Excel Programming 5 April 18th 04 12:59 PM


All times are GMT +1. The time now is 07:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"