PC Review


Reply
Thread Tools Rate Thread

Can't use COUNT function to count.csv rows?

 
 
Simon
Guest
Posts: n/a
 
      11th Jul 2008
Dear All,

I populate a csv file using data from our data warehouse and import
it as .csv.

I wish to Activate that file and count the number of rows and record
this in another workbooks sheet.

E.g.

In the CSV file

Dim Work As Workbook
Dim Figures As Workbook

Set Work = Workbooks.Open("N:\Work.csv")
Set Figures = Workbooks.Open("N:\mmyy.xls")

Work.Activate
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
myCount = Selection.Rows.Count
Figures.Activate
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
myCount.Paste

The xlDown is to skip part the previous months result.
Why isn't the count working, do I need to convert the numbers? Should
I say the data (.dtf file) as a different format from the i-Series
insteand of .csv?

Thanks
 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      11th Jul 2008
Question: what are you pasting, there is not copy? The figures.activate may
be causing problems. Using Select method can create lots of problems. It is
better to set Variables and use WITH method.

Dim Work As Workbook
Dim Figures As Workbook

Set Work = Workbooks.Open("N:\Work.csv")
Set Figures = Workbooks.Open("N:\mmyy.xls")

with Work
Set Lastcell = .Range("A1").End(xlDown)
Set Countrange = .Range(.Range("A1"), LastCell)
myCount = Countrange.Rows.Count
Figures.Activate
LastCell.Offset(1, 0).Paste
end with

"Simon" wrote:

> Dear All,
>
> I populate a csv file using data from our data warehouse and import
> it as .csv.
>
> I wish to Activate that file and count the number of rows and record
> this in another workbooks sheet.
>
> E.g.
>
> In the CSV file
>
> Dim Work As Workbook
> Dim Figures As Workbook
>
> Set Work = Workbooks.Open("N:\Work.csv")
> Set Figures = Workbooks.Open("N:\mmyy.xls")
>
> Work.Activate
> Range("A1").Select
> Range(Selection, Selection.End(xlDown)).Select
> myCount = Selection.Rows.Count
> Figures.Activate
> Range("A1").Select
> Selection.End(xlDown).Select
> ActiveCell.Offset(1, 0).Select
> myCount.Paste
>
> The xlDown is to skip part the previous months result.
> Why isn't the count working, do I need to convert the numbers? Should
> I say the data (.dtf file) as a different format from the i-Series
> insteand of .csv?
>
> Thanks
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
datatable rows count and dataview count differ John Hui Microsoft ADO .NET 4 3rd Aug 2010 10:26 PM
Count of Worksheet rows and recording this count mikerobe Microsoft Excel Programming 2 21st Mar 2007 02:17 AM
Count rows and insert number to count them. =?Utf-8?B?TWV4?= Microsoft Excel Misc 6 23rd Aug 2006 02:29 AM
Re: how do i count rows, and count them by color or a highlight? blue. Frank Kabel Microsoft Excel Worksheet Functions 0 9th Sep 2004 10:05 PM
I am adding a new row to the datagrid dynamically but if i use the Count property of Item it is not showing the count of the new rows being added Praveen Balanagendra via .NET 247 Microsoft ASP .NET 2 6th Jun 2004 08:16 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:05 PM.