If then statement

H

hello

how do I pick a group of rows out of a worksheet to copy to a new worksheet
that are in bold. I have went thru the sheet highlighted in bold the ones I
want to keep and would like to pick them all up at once to copy to a new
worksheet? thanks
 
D

dnickelson

a manual way would be to hold the Ctrl key down as you select the row
Number on the left, then selecting copy. Pasting to new sheet,
however, will not spread them out in their original layout, it will
paste them in the same order, but they will be together.
 
D

dnickelson

sorry, wasn't reading your subject along with the question.

I checked on a couple if options, didn't find anything, cell() doesn't
have any way of checking on the 'boldness' of a cell, not sure of the
VB code syntax for checking to see if a cell is bold.

again, sorry for the false response.
 
G

GB

hello said:
how do I pick a group of rows out of a worksheet to copy to a new worksheet
that are in bold. I have went thru the sheet highlighted in bold the ones I
want to keep and would like to pick them all up at once to copy to a new
worksheet? thanks

This sort of does it:

Public Sub test()
Dim MyRange As Range
Dim MySelection As Range

Set MySelection = Range("1:1")

For Each MyRange In ActiveSheet.UsedRange
If MyRange.Font.Bold = True Then
Set MySelection = Union(MySelection, MyRange.EntireRow)
End If
Next

MySelection.Select

End Sub

I say it sort of does it because it includes row 1 in the selected range
whether it is bold or not. I found that I had to start with something in the
Myselection range in order to get the union method to work, so I arbitrarily
included row 1. Does anyone know how to get round that?

Geoff
 
G

GB

This works better:

Public Sub test()
Dim MyRange As Range
Dim MySelection As Range

For Each MyRange In ActiveSheet.UsedRange
If MyRange.Font.Bold = True Then
If MySelection Is Nothing Then Set MySelection = MyRange
Set MySelection = Union(MySelection, MyRange.EntireRow)
End If
Next

MySelection.Select

End Sub


Geoff
 

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