Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Grrrr...Range on another sheet trouble...

Hi, I am a bit stuck on the macro below.
If I put the 'Dataunits' range on the same sheet as the
countif "DataInput")it works fine, but I cannot get it to
look for the data on the other sheet... any ideas...
? is the syntax wrong for the data range?

Cheers...

ste



Sub DataCount()

Dim xlrow As Long

Dataunits = Sheets("TheData").Range("DF3:AF10000")

Sheets("DataInput").Select

xlrow = 152

Do While Not (ActiveSheet.Cells(xlrow, 13).Value = "")

'Collate all data
ActiveSheet.Cells(xlrow, 16).Formula = "=countif(" & Dataunits & ", " &
ActiveSheet.Cells(xlrow, 13).Value & ")"
'Change formula to values
ActiveSheet.Cells(xlrow, 16).Value = ActiveSheet.Cells(xlrow, 16).Value

xlrow = xlrow + 1

Loop

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Grrrr...Range on another sheet trouble...

how is dataunits defined...stick an
OPTIONS EXPLICIT at the start of the module

your formula should look like
=COUNTIF(C1:C10,what)
or
=COUNTIF(sheetname!C1:C10,what)

use F8 to step through the code and in the immediate window
?"=countif(" & Dataunits & ", " & ActiveSheet.Cells(xlrow, 13).Value & ")"



"ste mac" wrote:

Hi, I am a bit stuck on the macro below.
If I put the 'Dataunits' range on the same sheet as the
countif "DataInput")it works fine, but I cannot get it to
look for the data on the other sheet... any ideas...
? is the syntax wrong for the data range?

Cheers...

ste



Sub DataCount()

Dim xlrow As Long

Dataunits = Sheets("TheData").Range("DF3:AF10000")

Sheets("DataInput").Select

xlrow = 152

Do While Not (ActiveSheet.Cells(xlrow, 13).Value = "")

'Collate all data
ActiveSheet.Cells(xlrow, 16).Formula = "=countif(" & Dataunits & ", " &
ActiveSheet.Cells(xlrow, 13).Value & ")"
'Change formula to values
ActiveSheet.Cells(xlrow, 16).Value = ActiveSheet.Cells(xlrow, 16).Value

xlrow = xlrow + 1

Loop

End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 117
Default Grrrr...Range on another sheet trouble...

Thanks for you help Patrick..

If I stick OPTION EXPLICIT at the start, it gives me 'Variable not
defined' do I
DIM it as a range? if the raw data is on the same sheet as the countif,
it all works
fine, there is just a bit too much to have everything on the same
sheet...

Should I DIM the range and work from there?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Grrrr...Range on another sheet trouble...

yes

again, read my response with regards to how the formula should look.

I have a problem with the original question in that I can't see how a range
of cells can be used in your formula.


"ste mac" wrote:

Thanks for you help Patrick..

If I stick OPTION EXPLICIT at the start, it gives me 'Variable not
defined' do I
DIM it as a range? if the raw data is on the same sheet as the countif,
it all works
fine, there is just a bit too much to have everything on the same
sheet...

Should I DIM the range and work from there?


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
Trouble getting Unique Dates from Range Mark Excel Programming 4 September 3rd 05 12:33 AM
Sales Report Grrrr jshafer817 Excel Worksheet Functions 7 August 1st 05 04:44 AM
Time Sheet for my org Im still having trouble Jesse_Norris Excel Discussion (Misc queries) 4 July 30th 05 06:28 AM
Trouble Naming Range Michael Smith Excel Programming 3 February 24th 05 05:46 PM
I have trouble in the hidden sheet range kvenku[_22_] Excel Programming 3 June 23rd 04 05:24 AM


All times are GMT +1. The time now is 12:50 AM.

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"