Reference separate sheet but omit blanks in specific columns

nc_waggoner

New Member
Joined
Sep 2, 2016
Messages
21
Hi, my goal is to create a reference sheet that only displays rows with valid data. In the below example (Sheet 1), I would like to display the same information on another sheet (Sheet 2) but omit the entire row for samples 4 and 7 due to one of the tests being blank. Does anyone know how to accomplish this?

[TABLE="******* 583"]
<tbody>[TR]
[TD]Date[/TD]
[TD]Sample[/TD]
[TD]Test 1[/TD]
[TD]Test 2[/TD]
[TD]Difference[/TD]
[/TR]
[TR]
[TD]8/24/2016[/TD]
[TD]1[/TD]
[TD]35.1[/TD]
[TD]35.7[/TD]
[TD]-0.6[/TD]
[/TR]
[TR]
[TD]8/25/2016[/TD]
[TD]2[/TD]
[TD]34.8[/TD]
[TD]35.3[/TD]
[TD]-0.5[/TD]
[/TR]
[TR]
[TD]8/26/2016[/TD]
[TD]3[/TD]
[TD]36.1[/TD]
[TD]37.5[/TD]
[TD]-1.4[/TD]
[/TR]
[TR]
[TD]8/27/2016[/TD]
[TD]4[/TD]
[TD]35.7[/TD]
[TD] [/TD]
[TD]35.7[/TD]
[/TR]
[TR]
[TD]8/28/2016[/TD]
[TD]5[/TD]
[TD]35.4[/TD]
[TD]36.4[/TD]
[TD]-1[/TD]
[/TR]
[TR]
[TD]8/29/2016[/TD]
[TD]6[/TD]
[TD]34.9[/TD]
[TD]36.2[/TD]
[TD]-1.3[/TD]
[/TR]
[TR]
[TD]8/30/2016[/TD]
[TD]7[/TD]
[TD] [/TD]
[TD]37.1[/TD]
[TD]-37.1[/TD]
[/TR]
[TR]
[TD]8/31/2016[/TD]
[TD]8[/TD]
[TD]33.2[/TD]
[TD]34.8[/TD]
[TD]-1.6[/TD]
[/TR]
</tbody><colgroup><col><col><col><col><col></colgroup>[/TABLE]
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Welcome to Board....:)

Are you looking for VBA or non-VBA solution...?
 
Last edited:
Upvote 0
if yes... then here is the solution.

Code:
Sub test()
Dim I As Long
Dim ws As Worksheet
Dim lstRow As Long
Dim lstCol As Long
Dim sht As Worksheet


Set sht = ThisWorkbook.Worksheets("sheet2")
Set ws = ThisWorkbook.Worksheets("sheet1")
sht.Cells.Clear


lstRow = ws.Cells(Rows.Count, 1).End(xlUp).Row
lstCol = ws.Cells(1, Columns.Count).End(xlToLeft).Column


For I = 1 To lstRow


   If ws.Cells(I, 3) <> "" And ws.Cells(I, 4) <> "" Then '''here you can even more criteria
      ws.Cells(I, 1).Resize(1, lstCol - 1).Copy
      sht.Activate
      sht.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Select
      sht.Paste
      Application.CutCopyMode = False
   End If


Next I


End Sub
 
Upvote 0
Thanks Mukeshy. Macro is a better option so long as I can decipher it enough to understand it. I'm ok at them but not incredibly advanced. A few things:
1. Awesome profile pic. I'm a big Flash fan myself
2. The macro cuts off the Difference column. How can I adjust this? This is important because this was just an example and there are quite a few more columns.
3. The sheet I want to reference will be in a different workbook all together...a sharepoint file to be exact. Any issues you see with that?
 
Upvote 0
thanks bro..

just change this " ws.Cells(I, 1).Resize(1, lstCol - 1).Copy" to ws.Cells(I, 1).Resize(1, lstCol ).Copy
 
Upvote 0
3. The sheet I want to reference will be in a different workbook all together...a sharepoint file to be exact. Any issues you see with that?

As long sheet names are same there won't be any issue ....if sheet name gets change then you need to change in code.
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top