D
Dave Peterson
I tried this:
I put put headers in row 1.
I merged A2:A4, A5:A7, A8:10, A11:A13, A14:A16
I left B2:B16 unmerged.
I used this as my test data:
Row# ColA ColB
1 a c
2 aa 1
3 2
4 3
5 bb 4
6 2
7 3
8 aa 7
9 2
10 9
11 dd 4
12 5
13 6
14 ee 7
15 8
16 9
Since you showed the middle row of the merged area as visible, I figured that
you filtered on a column that wasn't merged. (When I filtered on column A, I
saw the toprow of the merged area.)
I filtered column B to show just the 2's:
I saw this:
Row# ColA ColB
1 a c
3 aa 2
6 bb 2
9 aa 2
The middle row of the merged area showed up in the filter.
I ran this code:
Option Explicit
Sub testme()
Dim myRng As Range
Dim myArea As Range
With ActiveSheet.AutoFilter.Range
If .Columns(1).Cells _
.SpecialCells(xlCellTypeVisible).Cells.Count < 2 Then
MsgBox "not enough visible cells"
Exit Sub
Else
Set myRng = .Resize(.Rows.Count - 1, 1).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)
myRng.Cells(1).Select
MsgBox myRng.Cells(1).Address
End If
End With
End Sub
I got $A$3 back in the message box and $a$3 was selected in the worksheet.
It seemed to work ok for me in xl2002.
So what version of excel are you using--merged cells have become easier to work
with in later versions of excel since they were introduced in xl97.
And if I misunderstood your data layout, maybe you could go into more
specifics. I don't think I can offer anything more without more info.
I put put headers in row 1.
I merged A2:A4, A5:A7, A8:10, A11:A13, A14:A16
I left B2:B16 unmerged.
I used this as my test data:
Row# ColA ColB
1 a c
2 aa 1
3 2
4 3
5 bb 4
6 2
7 3
8 aa 7
9 2
10 9
11 dd 4
12 5
13 6
14 ee 7
15 8
16 9
Since you showed the middle row of the merged area as visible, I figured that
you filtered on a column that wasn't merged. (When I filtered on column A, I
saw the toprow of the merged area.)
I filtered column B to show just the 2's:
I saw this:
Row# ColA ColB
1 a c
3 aa 2
6 bb 2
9 aa 2
The middle row of the merged area showed up in the filter.
I ran this code:
Option Explicit
Sub testme()
Dim myRng As Range
Dim myArea As Range
With ActiveSheet.AutoFilter.Range
If .Columns(1).Cells _
.SpecialCells(xlCellTypeVisible).Cells.Count < 2 Then
MsgBox "not enough visible cells"
Exit Sub
Else
Set myRng = .Resize(.Rows.Count - 1, 1).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)
myRng.Cells(1).Select
MsgBox myRng.Cells(1).Address
End If
End With
End Sub
I got $A$3 back in the message box and $a$3 was selected in the worksheet.
It seemed to work ok for me in xl2002.
So what version of excel are you using--merged cells have become easier to work
with in later versions of excel since they were introduced in xl97.
And if I misunderstood your data layout, maybe you could go into more
specifics. I don't think I can offer anything more without more info.
Only the rows are merged. E.g 631 to 633, 634 to 636, 637 to 639
F G H