LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,718
Default Error without activating worksheet

Your " Range("C65536").End(xlUp)) " is unmodified so it always refers to the
active sheet

With ThisWorkbook.Worksheets("Report")
Cuniquecount = CountUniqueValues(.Range(("c2"),
..Range("c65536").End(xlUp)))
duniquecount = CountUniqueValues(.Range(("d2"),
..Range("d65536").End(xlUp)))
euniquecount = CountUniqueValues(.Range(("e2"),
..Range("e65536").End(xlUp)))
End With


--
Jim
"Raj" wrote in message
...
| Hi,
|
| Please help me with the following code:
|
| Sub TestforUniqueness()
| Dim Cuniquecount As Long
| Dim duniquecount As Long
| Dim euniquecount As Long
| Cuniquecount =
| CountUniqueValues(ThisWorkbook.Worksheets("Report" ).Range(("c2"),
| Range("c65536").End(xlUp)))
| duniquecount =
| CountUniqueValues(ThisWorkbook.Worksheets("Report" ).Range(("d2"),
| Range("d65536").End(xlUp)))
| euniquecount =
| CountUniqueValues(ThisWorkbook.Worksheets("Report" ).Range(("e2"),
| Range("e65536").End(xlUp)))
| MsgBox Cuniquecount
| MsgBox duniquecount
| MsgBox euniquecount
| End Sub
|
| The workbook has two sheets: "Summary" and "Reports"
| When the following code is run and the Active sheet is other than
| Reports, it gives an application or object defined error. If add the
| line "Worksheets("Reports").activate" then the code works well. Why
| does this happen? Any way of doing this without activating the
| worksheet.? (Before running this sub the earlier code writes some
| values to the "Summary" sheet. But the summary sheet has not been
| activated in the code before writing those values.
|
| Thanks in advance for the help.
|
| Regards,
| Raj


 
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
Activating a Worksheet? Kenny R Excel Discussion (Misc queries) 3 December 8th 06 05:15 PM
Worksheet activating JamesM[_2_] Excel Programming 0 September 28th 04 04:34 PM
Activating a worksheet DJH Excel Programming 2 August 10th 04 04:20 PM
Error on activating a window a open workbook Hari[_3_] Excel Programming 1 June 11th 04 12:58 AM
Error 40036 when activating a sheet shinydiamond Excel Programming 5 February 11th 04 10:11 PM


All times are GMT +1. The time now is 10:29 PM.

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

About Us

"It's about Microsoft Excel"