Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
FA FA is offline
external usenet poster
 
Posts: 18
Default macro that displays function from 2 columns

I have 2 columns in my spreadsheet that contain either True or False entries.
I'm looking to create a macro that will display the True entries from either
column.
If my sheet looks like this,

A B
1 True False
2 True False
3 False False
4 False True
5 False True

Then I want the macro to display only rows 1,2,4 & 5. The colums are never
both True so I don't have to worry about that.
I'm stuck with coming up with a function that will work, any help would be
appreciated!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default macro that displays function from 2 columns

Try the below macro...

Sub Macro()
Dim lngRow As Long
For lngRow = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If Range("A" & lngRow) + Range("b" & lngRow) = 0 Then _
Rows(lngRow).Hidden = True
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"FA" wrote:

I have 2 columns in my spreadsheet that contain either True or False entries.
I'm looking to create a macro that will display the True entries from either
column.
If my sheet looks like this,

A B
1 True False
2 True False
3 False False
4 False True
5 False True

Then I want the macro to display only rows 1,2,4 & 5. The colums are never
both True so I don't have to worry about that.
I'm stuck with coming up with a function that will work, any help would be
appreciated!

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default macro that displays function from 2 columns

If you have text values try

Sub Macro()
Dim lngRow As Long
For lngRow = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If Range("A" & lngRow) = "False" And Range("b" & lngRow) = "False" Then _
Rows(lngRow).Hidden = True
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

Try the below macro...

Sub Macro()
Dim lngRow As Long
For lngRow = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If Range("A" & lngRow) + Range("b" & lngRow) = 0 Then _
Rows(lngRow).Hidden = True
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"FA" wrote:

I have 2 columns in my spreadsheet that contain either True or False entries.
I'm looking to create a macro that will display the True entries from either
column.
If my sheet looks like this,

A B
1 True False
2 True False
3 False False
4 False True
5 False True

Then I want the macro to display only rows 1,2,4 & 5. The colums are never
both True so I don't have to worry about that.
I'm stuck with coming up with a function that will work, any help would be
appreciated!

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default macro that displays function from 2 columns

Sub DoubleFalseHide()
n = Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To n
v1 = Cells(i, 1).Value
v2 = Cells(i, 2).Value
If v1 = True Or v1 = "True" Then
Else
If v1 = True Or v2 = "True" Then
Else
Cells(i, 1).EntireRow.Hidden = True
End If
End If
Next
End Sub


This should work whether the cells contain text or booleans.
--
Gary''s Student - gsnu200901


"FA" wrote:

I have 2 columns in my spreadsheet that contain either True or False entries.
I'm looking to create a macro that will display the True entries from either
column.
If my sheet looks like this,

A B
1 True False
2 True False
3 False False
4 False True
5 False True

Then I want the macro to display only rows 1,2,4 & 5. The colums are never
both True so I don't have to worry about that.
I'm stuck with coming up with a function that will work, any help would be
appreciated!

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default macro that displays function from 2 columns

Assuming you have boolean true and false inthe cells and not text true and
false then...

Public Sub HideFalse()
Dim rng As Range
Dim rngToSearch As Range

With Sheets("Sheet1") 'Specify the sheet
Set rngToSearch = .Range(.Range("A1"), .Cells(Rows.Count, "A").End(xlUp))
End With

For Each rng In rngToSearch
If Not (rng.Value Or rng.Offset(0, 1).Value) Then _
rng.EntireRow.Hidden = True
Next rng

End Sub
--
HTH...

Jim Thomlinson


"FA" wrote:

I have 2 columns in my spreadsheet that contain either True or False entries.
I'm looking to create a macro that will display the True entries from either
column.
If my sheet looks like this,

A B
1 True False
2 True False
3 False False
4 False True
5 False True

Then I want the macro to display only rows 1,2,4 & 5. The colums are never
both True so I don't have to worry about that.
I'm stuck with coming up with a function that will work, any help would be
appreciated!

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
If, Or function or macro to compare 3 columns of numbers AuthorizedUserPF Excel Worksheet Functions 3 October 27th 08 04:39 PM
Function displays but not the result - cause????? Mark[_7_] Excel Worksheet Functions 3 August 8th 08 03:32 PM
The way the date displays in columns Patsy Caddy New Users to Excel 1 May 3rd 06 10:58 PM
Combo box in Excel that displays 2 columns ichu05 New Users to Excel 1 March 21st 06 08:32 PM
Formula window displays correct answer while cell displays incorre MMV Excel Worksheet Functions 3 November 10th 04 09:28 PM


All times are GMT +1. The time now is 06:37 AM.

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"