Row Height property

C

CY

A client has a spreadsheet with some rows set at either zero or close to
zero height and he wants to copy only those (what he calls)"hidden" rows to
another sheet for comparison to different data. I realize that he should
not have done it this way (better to have filtered the data) but he does not
want to go back and unhide and mark each row. Any way to create VBA - or
maybe an easier way - that looks at the row height property and returns the
values??

TIA
 
G

George Nicholson

Fire the client.

Bwahahah. Ok. That was fun. Here is some untested air code that will maybe
give you some ideas. This is only one possible approach:

Dim wksTarget as Worksheet
Dim rngSource as Range
Dim iTargRow as Long
Dim rw as Range

Set rngSource = ThisWorkbook.Sheets("SourceSheet").Range("A1:Z342")
Set wksTarget =ThisWorkbook.Sheets("TargetSheet")

iTargetRow = 2 'Assuming row 1 of target is column headers
For each rw in rngSource.Rows
If rw.Height < 2 Then
rw.EntireRow.Copy
wksTarget.Range("A" & iTargetRow).EntireRow.PasteSpecial _
Paste:=xlPasteValuesAndNumberFormats
End If
Next rw

- I arbitrarily used 2 for a RowHeight criteria. Depending on what your
client has actually done, you may need to adjust that.
- I used PasteSpecial to avoid copying the Rowheight that a straight paste
of an entire row would.

HTH & Good Luck,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top