select row if cell in column h is NOT blank

rburnet4

New Member
Joined
Dec 23, 2009
Messages
14
I'm trying to come up with a marco solution that will select rows if the cell in column H is NOT BLANK.

From there I think it will be rather easy to cut these rows and paste them in another workbook (that's filename does not change) at the end of the worksheet (in the first row that is completely blank).

Both workbooks only have one worksheet in them. Let me know what you think.
Thanks for all your help!!
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Try
Code:
Sub xyz()
With Range("H:H")
    Union(.SpecialCells(2), .SpecialCells(-4123)).EntireRow.Select
End With
End Sub
Although your approach seems a rather inefficient way to achieve what you seem to want.
 
Upvote 0
This macro allows to you to select rows corresponding to cells in column H not blanks:
Code:
Sub test()
nr = Cells(Rows.Count, 8).End(xlUp).Row
For r = 1 To nr
  If Cells(r, 8) <> "" Then
     Rng = Rng & r & ":" & r & ", "
  End If
Next
rnge = Mid(Rng, 1, Len(Rng) - 2)
Range(rnge).Select
End Sub
 
Upvote 0
The above code of mine works only if there are formulae in one or more of the cells in ColH.

If you only have values or blanks in ColH then this simpler version may do what you want
Code:
Sub xyz2()
Range("H:H").SpecialCells(2).EntireRow.Select
End Sub
 
Upvote 0
The above code of mine works only if there are formulae in one or more of the cells in ColH.

If you only have values or blanks in ColH then this simpler version may do what you want
Code:
Sub xyz2()
Range("H:H").SpecialCells(2).EntireRow.Select
End Sub
Hi rugila...
in argument of specialcells there is a number that correspondind to xlCellTypeConstants
Can you tell me other numbers with their correspondance??
Thanks
 
Upvote 0
Am I missing something? Can't you just AutoFilter (either manually or via code) and copy the results to the other workbook?
lenze
 
Upvote 0
Hi rugila...
in argument of specialcells there is a number that correspondind to xlCellTypeConstants
Can you tell me other numbers with their correspondance??
Thanks
A convenient reference, at least for XL2003, is http://msdn.microsoft.com/en-us/library/aa213567(office.11).aspx
There are some valid specialcell numbers which this doesn't include though, like SpecialCells(8), whch you may need to experiment with a bit to see just what it means. I don't think it's got a convenient verbal summary like CellTypeBlanks, etc.
 
Upvote 0
Am I missing something? Can't you just AutoFilter (either manually or via code) and copy the results to the other workbook?
lenze
I think OP would probably welcome details on this or other of the several efficient means of solving his/her overall problem.

So if you'd like to detail your approach in the specific context of OP's problem I'm sure it would be welcomed.

For my part I was solely considering the narrower question (as OP specifically asked) of selecting only those entire rows up to the last used row that don't have blanks in ColumnH. Just seemed like a problem of some interest in its own right.
 
Upvote 0
This macro allows to you to select rows corresponding to cells in column H not blanks:
Code:
Sub test()
nr = Cells(Rows.Count, 8).End(xlUp).Row
For r = 1 To nr
  If Cells(r, 8) <> "" Then
     Rng = Rng & r & ":" & r & ", "
  End If
Next
rnge = Mid(Rng, 1, Len(Rng) - 2)
Range(rnge).Select
End Sub

This is perfect. One thing I did not think of though... How do I make sure the Macro does not pick up the first two rows (ie headers)?
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
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