Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Counting Range Data From Different Sheet


I am using the following code to count the no of entries in colA i
sheet2
I am currently in sheet1

Sub check()
Set myrange = Sheets("sheet2").Range(Cells(1, 1), Cells(4000, 1))
MsgBox Application.CountA(myrange)
End Sub

This gives an error as follows

"run time error 1004

application or object defined error"

but when I am in sheet2 and run this macro there is no error

how to avoid this

--
chandran1
-----------------------------------------------------------------------
chandran19's Profile: http://www.excelforum.com/member.php...fo&userid=1449
View this thread: http://www.excelforum.com/showthread.php?threadid=26121

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Counting Range Data From Different Sheet

Hi chandran19,

something like:
Sub check()
Dim myRange As Range
Sheets("sheet2").Activate
Set myRange = Range(Cells(1, 1), Cells(4000, 1))
MsgBox Application.CountA(myRange)
End Sub

Best regards

Wolf


-----Original Message-----

I am using the following code to count the no of entries

in colA in
sheet2
I am currently in sheet1

Sub check()
Set myrange = Sheets("sheet2").Range(Cells(1, 1), Cells

(4000, 1))
MsgBox Application.CountA(myrange)
End Sub

This gives an error as follows

"run time error 1004

application or object defined error"

but when I am in sheet2 and run this macro there is no

error

how to avoid this?


--
chandran19
---------------------------------------------------------

---------------
chandran19's Profile:

http://www.excelforum.com/member.php?
action=getinfo&userid=14497
View this thread:

http://www.excelforum.com/showthread...hreadid=261217

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Counting Range Data From Different Sheet

Hi

Use it like this

In your example "cells" in the code will use the cells on the activesheet
See the dot before it in my example

Sub check()
Dim myrange As Range
With Sheets("sheet2")
Set myrange = .Range(.Cells(1, 1), .Cells(4000, 1))
End With
MsgBox Application.CountA(myrange)
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"chandran19" wrote in message ...

I am using the following code to count the no of entries in colA in
sheet2
I am currently in sheet1

Sub check()
Set myrange = Sheets("sheet2").Range(Cells(1, 1), Cells(4000, 1))
MsgBox Application.CountA(myrange)
End Sub

This gives an error as follows

"run time error 1004

application or object defined error"

but when I am in sheet2 and run this macro there is no error

how to avoid this?


--
chandran19
------------------------------------------------------------------------
chandran19's Profile: http://www.excelforum.com/member.php...o&userid=14497
View this thread: http://www.excelforum.com/showthread...hreadid=261217



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
Counting data from sheet to sheet Help with cell function[_2_] Excel Discussion (Misc queries) 3 September 30th 09 07:19 PM
Counting data in a range Glenn L. Excel Worksheet Functions 7 July 14th 08 06:01 PM
counting occurences in data range (e.g 31-60) Chuck Excel Worksheet Functions 2 June 28th 06 02:09 PM
counting cells in a data range that meet 3 specific conditions bekah7 Excel Discussion (Misc queries) 3 October 1st 05 06:21 AM
Counting data in a range Stuart Excel Discussion (Misc queries) 4 July 12th 05 09:44 PM


All times are GMT +1. The time now is 08:47 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"