Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default count number of non empty columns

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!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default count number of non empty columns

Hi Arne

Just a little typo i think

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

Laterz

S


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default count number of non empty columns

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

"Arne Hegefors" wrote in message
...
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
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
How to count the number of cells not empty? Eric Excel Discussion (Misc queries) 9 April 19th 10 09:46 PM
Count the number of columns on row that are not empty within a ran Mathew Excel Discussion (Misc queries) 3 March 30th 10 07:34 PM
count number of duplicates between 2 columns SteveC Excel Discussion (Misc queries) 8 February 2nd 09 07:07 PM
Pivot Table - How do I count number of columns? vicky Excel Discussion (Misc queries) 5 August 8th 06 01:26 PM
To find number of non-empty cells across columns Mark Stephens[_3_] Excel Programming 1 July 2nd 05 02:23 AM


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