Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 397
Default IF Cell contents = "a" then hide row



Hi guys,

I have in column K three possible types of data, a,b or c (only one per
cell)

If the value = a or b I want the row to be visible (ie hide all rows
that contain c)

I then need anotehr set of VB to to repeat the excercise for the other
option - ie first unide all, then if value = b or c row is visible (ie
hide all rows that contain a)

If I can just be helped with the first scenario, Im sure I could
replicate it for the second....

Thanks!!!!!

Regards

D



*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default IF Cell contents = "a" then hide row

This would leave all rows with "b" or "c" values
within myRange visible.

Sub hiderow()
Dim r As Range
Set myRange = ActiveSheet.Range("K2:K100")
For Each r In myRange
If r.Value < "a" Then
r.EntireRow.Hidden = True
End If
Next
End Sub



"Darin Kramer" wrote:



Hi guys,

I have in column K three possible types of data, a,b or c (only one per
cell)

If the value = a or b I want the row to be visible (ie hide all rows
that contain c)

I then need anotehr set of VB to to repeat the excercise for the other
option - ie first unide all, then if value = b or c row is visible (ie
hide all rows that contain a)

If I can just be helped with the first scenario, Im sure I could
replicate it for the second....

Thanks!!!!!

Regards

D



*** Sent via Developersdex http://www.developersdex.com ***

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default IF Cell contents = "a" then hide row

hide rows a & b
Sub Hideab()

Dim LastRow As Long

'last row in Col.K
LastRow = Cells(Rows.Count, "K").End(xlUp).Row

'unhides all rows
Cells.EntireRow.Hidden = False

'hides all rows with a or b in Col.K
For i = 1 To LastRow
If Cells(i, 11) = "a" Or Cells(i, 11) = "b" Then
Rows(i).EntireRow.Hidden = True
End If
Next i

End Sub

Sub Hidebc()

Dim LastRow As Long

'last row in Col.K
LastRow = Cells(Rows.Count, "K").End(xlUp).Row

'unhides all rows
Cells.EntireRow.Hidden = False

'hides all rows with b or c in Col. K
For i = 1 To LastRow
If Cells(i, 11) = "b" Or Cells(i, 11) = "c" Then
Rows(i).EntireRow.Hidden = True
End If
Next i

End Sub

"Darin Kramer" wrote:



Hi guys,

I have in column K three possible types of data, a,b or c (only one per
cell)

If the value = a or b I want the row to be visible (ie hide all rows
that contain c)

I then need anotehr set of VB to to repeat the excercise for the other
option - ie first unide all, then if value = b or c row is visible (ie
hide all rows that contain a)

If I can just be helped with the first scenario, Im sure I could
replicate it for the second....

Thanks!!!!!

Regards

D



*** Sent via Developersdex http://www.developersdex.com ***

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 397
Default IF Cell contents = "a" then hide row



Thanks Guys - works perfectly!

*** Sent via Developersdex http://www.developersdex.com ***
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
Convert cell "contents" into a "comment" Ryan Excel Discussion (Misc queries) 4 October 3rd 08 11:34 PM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
conditional formatting "if part of cell contents contains string" tom ossieur Excel Worksheet Functions 1 March 13th 07 11:11 AM
how to increase size of "name box" and "contents of cell " displa. Stubby- LIBERTY New Users to Excel 2 February 22nd 07 06:43 PM
if one cell has "X" textin contents, then pull cell "Y"... azazel Excel Worksheet Functions 3 October 24th 05 05:43 PM


All times are GMT +1. The time now is 10:19 AM.

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"