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

All:

I read through numerous similar postings and stilll could not get my
simple UDF to work.

Function CountColumns(RngStartingPoint As Range) As Integer
CountColumns = Range(Cells(RngStartingPoint), Cells(1,
Cols.Count).End(xlToLeft))
End Function

I want to be able to count the number of blank cells from a given range
("AA1") back to a populated cell ("G1"). The populated cells contain
an "x".

Any assistance as to why this function is incorrect, would be greatly
appreciated.

Cheers.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Finding number of empty cells

Function CountColumns(RngStartingPoint As Excel.Range) As Long
CountColumns = Application.CountBlank(Range(RngStartingPoint, _
Cells(1, Columns.Count).End(xlToLeft)))
End Function

Sub CallFunction()
MsgBox CountColumns(Range("G1"))
End Sub
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Floyd"
wrote in message
All:
I read through numerous similar postings and stilll could not get my
simple UDF to work.

Function CountColumns(RngStartingPoint As Range) As Integer
CountColumns = Range(Cells(RngStartingPoint), Cells(1,
Cols.Count).End(xlToLeft))
End Function

I want to be able to count the number of blank cells from a given range
("AA1") back to a populated cell ("G1"). The populated cells contain
an "x".
Any assistance as to why this function is incorrect, would be greatly
appreciated.
Cheers.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Finding number of empty cells

Thank you.

Cheers.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Finding number of empty cells

Trial Number 2:

The "blank" cells contain the following formula, which may be
interfering with the calculation:
=IF(OR(AND(V2=$G129,V2<$J128),AND(V2=$J129,V2<$J 130)),"X"," ")

This function
Function CountColumns(RngStartingPoint As Excel.Range) As Long
CountColumns = Application.CountBlank(Range(RngStartingPoint, _
Cells(1, Columns.Count).End(xlToLeft)))
End Function

provides wildly large numbers such as 616 instead of 2.

Should I have modified the "1" to match the row for others rows besides
one?

Also, is the countblank being messed up due to the equation that is in
those cells?

Thanks in advance.

I truly appreciate your responses.

Cheers.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Finding number of empty cells

Formulas should not cause a problem.
The first number in Cells(1, 2) specifies the row number.
The second number specifies the column number.
The above is Range("B1")

When specifying a range, you normally use the top left cell
and the bottom right cell. However, either one can come first.
Range("G1", "J10") is the same as Range("J10", "G1")
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Floyd"
wrote in message
Trial Number 2:
The "blank" cells contain the following formula, which may be
interfering with the calculation:
=IF(OR(AND(V2=$G129,V2<$J128),AND(V2=$J129,V2<$J 130)),"X"," ")

This function
Function CountColumns(RngStartingPoint As Excel.Range) As Long
CountColumns = Application.CountBlank(Range(RngStartingPoint, _
Cells(1, Columns.Count).End(xlToLeft)))
End Function

provides wildly large numbers such as 616 instead of 2.
Should I have modified the "1" to match the row for others rows besides
one?
Also, is the countblank being messed up due to the equation that is in
those cells?
Thanks in advance.
I truly appreciate your responses.
Cheers.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Finding number of empty cells

Mr. Cone,

Thanks for your continue persistence.

I am using the following two functions based on your response to
bracket data in a row.

Function CountColumnsRight(RngStartingPoint As Excel.Range) As Long
CountColumnsRight = Application.CountBlank(Range(RngStartingPoint, _
Cells(4, Columns.Count).End(xlToLeft)))
End Function

Function CountColumnsLeft(RngStartingPoint As Excel.Range) As Long
CountColumnsLeft = Application.CountBlank(Range(RngStartingPoint, _
Cells(4, Columns.Count).End(xlToRight)))
End Function

If I delete the worksheet equation, then the CountColumnsRight UDF
works, but not the other.

I tried using your function with COUNTIF, IsEmpty and IsNull, but I
couldn't get it to work.

Is there a way to modify my worksheet equations, such that it will work
with your function?

Any other suggestions?

Cheers.


[The server temporarily went down. I hope this doesn't get posted
twice.]

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Finding number of empty cells

Try the functions with the MsgBox line added in each.
I suspect the ranges Excel uses are not what you think they are...

Function CountColumnsRight(RngStartingPoint As Excel.Range) As Long
MsgBox Range(RngStartingPoint, Cells(4, Columns.Count).End(xlToLeft)).Address

CountColumnsRight = Application.CountBlank(Range(RngStartingPoint, _
Cells(4, Columns.Count).End(xlToLeft)))
End Function
'---
Function CountColumnsLeft(RngStartingPoint As Excel.Range) As Long
MsgBox Range(RngStartingPoint, Cells(4, Columns.Count).End(xlToRight)).Address

CountColumnsLeft = Application.CountBlank(Range(RngStartingPoint, _
Cells(4, Columns.Count).End(xlToRight)))
End Function
--
Jim Cone
San Francisco, USA
http://www.officeletter.com/blink/specialsort.html


"Floyd"
wrote in message
Mr. Cone,
Thanks for your continue persistence.
I am using the following two functions based on your response to
bracket data in a row.

Function CountColumnsRight(RngStartingPoint As Excel.Range) As Long
CountColumnsRight = Application.CountBlank(Range(RngStartingPoint, _
Cells(4, Columns.Count).End(xlToLeft)))
End Function

Function CountColumnsLeft(RngStartingPoint As Excel.Range) As Long
CountColumnsLeft = Application.CountBlank(Range(RngStartingPoint, _
Cells(4, Columns.Count).End(xlToRight)))
End Function

If I delete the worksheet equation, then the CountColumnsRight UDF
works, but not the other.
I tried using your function with COUNTIF, IsEmpty and IsNull, but I
couldn't get it to work.
Is there a way to modify my worksheet equations, such that it will work
with your function?
Any other suggestions?
Cheers.

[The server temporarily went down. I hope this doesn't get posted
twice.]

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Finding number of empty cells

Mr. Cone,

That is helpful. For the CountColumnsRight UDF, it is returning a
single cell which is the one that is passed to it.

I will keep beating on the computer to see, if I can get the equation
to grab the correct range. For whatever reason, the worksheet equation
is stopping it from grabbing the intended range.

Thank you for your time and assistance.

Cheers.

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Finding number of empty cells

Mr. Cone,

It is the Shift-Right or Left that is not recognizing the "X" from my
worksheet equation.

Any thoughts on this?

  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Finding number of empty cells

Mr. Cone,

I am using two equations based on yours.

Function CountColumnsRight(RngStartingPoint As Excel.Range) As Long
CountColumnsRight = Application.CountBlank(Range(RngStartingPoint, _
Cells(4, Columns.Count).End(xlToLeft)))
End Function

Function CountColumnsLeft(RngStartingPoint As Excel.Range) As Long
CountColumnsLeft = Application.CountBlank(Range(RngStartingPoint, _
Cells(4, Columns.Count).End(xlToRight)))
End Function

If I delete the worksheet equation, then the CountColumnsRight UDF
works but not the other.

Is there a way to use your UDF with a conditional statement, such as
COUNTIF, IsNull, IsEmpty, so that it will work with my worksheet
equation? I tried these, but I couldn't get it to work.

Sorry to keep this going.

Cheers.



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Finding number of empty cells

You lost me, there is no "shift" in the code.
Each function counts the blank cells in the range shown in the MsgBox.
Are the ranges shown the correct ones?
You must be able to tell Excel the exact location of the ranges or
nothing is going to work.
Jim Cone

"Floyd"
wrote in message

It is the Shift-Right or Left that is not recognizing the "X" from my
worksheet equation.
Any thoughts on this?

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
Finding data amongst empty cells James Excel Discussion (Misc queries) 6 November 10th 09 04:35 PM
Finding Empty Cells Bill[_30_] Excel Programming 2 February 20th 06 01:41 PM
Finding days between cells C and L where the cells may be empty Jack Excel Worksheet Functions 1 January 9th 06 06:47 PM
finding/highlighting empty cells Patrick[_4_] Excel Programming 1 October 1st 03 08:33 AM
Macro trouble finding 'empty' cells foamfollower Excel Programming 1 October 1st 03 02:59 AM


All times are GMT +1. The time now is 03:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"