Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default udf to hide a row

I have been muddling around trying to create a function that simply hides
(or unhides) 'its' row if another cells contents are greater than zero.
just need to know if it can be done, and, what might it look like.
Any help on same would be much appreciated
Thanks
David


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default udf to hide a row

Try using a macro rather than a UDF.
--
Gary''s Student


"David Henderson" wrote:

I have been muddling around trying to create a function that simply hides
(or unhides) 'its' row if another cells contents are greater than zero.
just need to know if it can be done, and, what might it look like.
Any help on same would be much appreciated
Thanks
David



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default udf to hide a row

Hi,
As n example this hides even rows:

Sub HideRow()
For r = 1 To 5
If Cells(r, 1) Mod 2 = 0 Then Rows(r).EntireRow.Hidden = True
Next r
End Sub


HTH
"David Henderson" wrote:

I have been muddling around trying to create a function that simply hides
(or unhides) 'its' row if another cells contents are greater than zero.
just need to know if it can be done, and, what might it look like.
Any help on same would be much appreciated
Thanks
David



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default udf to hide a row

many thanks
all the best
David
"Toppers" wrote in message
...
Hi,
As n example this hides even rows:

Sub HideRow()
For r = 1 To 5
If Cells(r, 1) Mod 2 = 0 Then Rows(r).EntireRow.Hidden = True
Next r
End Sub


HTH
"David Henderson" wrote:

I have been muddling around trying to create a function that simply hides
(or unhides) 'its' row if another cells contents are greater than zero.
just need to know if it can be done, and, what might it look like.
Any help on same would be much appreciated
Thanks
David





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default udf to hide a row

David,

The fact is, a UDF used in a worksheet cell is not permitted to change the
excel environment. this includes such things and changing formats, changing
the values of other cells or as in your case, hiding or unhiding rows or
columns. Even if you wrote a sub and called it from your UDF, this would
not work. What you can do is use the Worksheet_Calculate event to perform
this function

Right click on the sheet tab where you want this behavior and select View
code. In the left dropdown at the top of the module select Worksheet and in
the right dropdown at the top of the module select Calculate.

Private Sub Worksheet_Calculate()
Dim cell as Range
for each cell in Range("B2:B50")
if cell.Value < 10 then
cell.EntireRow.Hidden = True
else
cell.EntireRow.Hidden = False
end if
Next
End Sub

then in the cells in column B, you could have your formula (or UDF) to
determine whether the row should be hidden or not.

Adjust to suit your requirements.

--
Regards,
Tom Ogilvy

"David Henderson" wrote in message
...
many thanks
all the best
David
"Toppers" wrote in message
...
Hi,
As n example this hides even rows:

Sub HideRow()
For r = 1 To 5
If Cells(r, 1) Mod 2 = 0 Then Rows(r).EntireRow.Hidden = True
Next r
End Sub


HTH
"David Henderson" wrote:

I have been muddling around trying to create a function that simply

hides
(or unhides) 'its' row if another cells contents are greater than zero.
just need to know if it can be done, and, what might it look like.
Any help on same would be much appreciated
Thanks
David









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 do you hide/un-hide the grid lines ED Excel Discussion (Misc queries) 4 February 26th 13 03:22 PM
Want to Hide columns in spreadsheet but NOT hide data in chart. KrispyData Charts and Charting in Excel 1 March 20th 09 04:45 PM
hide code does not hide Wanna Learn Excel Discussion (Misc queries) 2 March 6th 08 07:21 PM
Hide And Un-hide Excel Toolbars Jim333[_4_] Excel Programming 3 July 2nd 05 08:00 PM
How do I hide a worksheet in Excel and use a password to un-hide . Dchung Excel Discussion (Misc queries) 3 December 2nd 04 06:24 AM


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