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?

DateSampleTest 1Test 2Difference
8/24/2016135.135.7-0.6
8/25/2016234.835.3-0.5
8/26/2016336.137.5-1.4
8/27/2016435.7 35.7
8/28/2016535.436.4-1
8/29/2016634.936.2-1.3
8/30/20167 37.1-37.1
8/31/2016833.234.8-1.6

<tbody>
</tbody><colgroup><col><col><col><col><col></colgroup>
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
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,214,944
Messages
6,122,387
Members
449,080
Latest member
Armadillos

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