PC Review


Reply
Thread Tools Rate Thread

count number of non empty columns

 
 
=?Utf-8?B?QXJuZSBIZWdlZm9ycw==?=
Guest
Posts: n/a
 
      9th Jul 2007
Hi! I am trying to count the number of non empty columns of a named range. I
use this "method" for rows and that works fine but I have trouble getting it
to work for columns (I only get 0 number of columns).

Set rngPL = ThisWorkbook.Sheets("P&L Matrix").Range("PL")
Dim NoRPL As Long
Dim NoCPL As Long
NoRPL = rngPL(1).End(xlDown).Row - rngPL(1).Row + 1 'number of rows
NoCPL = rngPL.End(xlRight).Column - rngPL.Column + 1

It is the last row that is for columns but it does not work. Would be most
gratefuk for any help!

 
Reply With Quote
 
 
 
 
Incidental
Guest
Posts: n/a
 
      9th Jul 2007
Hi Arne

Just a little typo i think

if you change from xlRight to xlToRight you should have more luck

Laterz

S


 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      9th Jul 2007
You might like these??
lr = Range("testrng").Cells.Find(what:="*", _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

lc = Range("testrng").Cells.Find(what:="*", _
SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column

MsgBox lr
MsgBox lc


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Arne Hegefors" <(E-Mail Removed)> wrote in message
news:7BA27CCB-4EC7-4D32-ACB4-(E-Mail Removed)...
> Hi! I am trying to count the number of non empty columns of a named range.
> I
> use this "method" for rows and that works fine but I have trouble getting
> it
> to work for columns (I only get 0 number of columns).
>
> Set rngPL = ThisWorkbook.Sheets("P&L Matrix").Range("PL")
> Dim NoRPL As Long
> Dim NoCPL As Long
> NoRPL = rngPL(1).End(xlDown).Row - rngPL(1).Row + 1 'number of rows
> NoCPL = rngPL.End(xlRight).Column - rngPL.Column + 1
>
> It is the last row that is for columns but it does not work. Would be most
> gratefuk for any help!
>


 
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
How to count the number of cells not empty? Eric Microsoft Excel Misc 9 19th Apr 2010 09:46 PM
Count the number of columns on row that are not empty within a ran Mathew Microsoft Excel Misc 3 30th Mar 2010 07:34 PM
Get count of active (non-empty) rows and columns =?Utf-8?B?YmFnYQ==?= Microsoft Excel Programming 3 6th Dec 2007 01:01 PM
To find number of non-empty cells across columns Mark Stephens Microsoft Excel Programming 1 2nd Jul 2005 02:23 AM
AVERAGE COLUMNS BUT NOT COUNT EMPTY CELLS =?Utf-8?B?TWFyY2lh?= Microsoft Excel Worksheet Functions 4 19th Jan 2004 05:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:30 PM.