ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to find cell with specific format? (https://www.excelbanter.com/excel-programming/384800-how-find-cell-specific-format.html)

NOPIK

How to find cell with specific format?
 
I want to speed up my select procedure. Is there any VBA method or
Excel function to find specified format (MergedCells in my case) in
Cells range?


joel

How to find cell with specific format?
 
I found this in the VBA help menu.

Set ma = Range("a3").MergeArea
If Range("a3").MergeCells Then
ma.Cells(1, 1).Value = "42"
End If


Letting VBA search a range is always faster than indexing rows and columns.
I usually do this

Set Myrange = Range("A1:Z:50)
For each MyCell in Myrange

Next MyCell



"NOPIK" wrote:

I want to speed up my select procedure. Is there any VBA method or
Excel function to find specified format (MergedCells in my case) in
Cells range?



Dave Peterson

How to find cell with specific format?
 
If you're using xl2002+, the Edit|Find has been enhanced to look for
formating--including merged cells (in my little test).

I'm not sure what you're doing, but this may help (for xl2k and below):

How about a little macro:

Option Explicit
Sub testme()

Dim myCell As Range
Dim resp As Long

For Each myCell In ActiveSheet.UsedRange.Cells
If myCell.MergeCells Then
If myCell.Address = myCell.MergeArea(1).Address Then
resp = MsgBox(prompt:="found: " _
& myCell.MergeArea.Address & vbLf & _
"Continue looking", Buttons:=vbYesNo)
If resp = vbNo Then
Exit Sub
End If
End If
End If
Next myCell

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm


NOPIK wrote:

I want to speed up my select procedure. Is there any VBA method or
Excel function to find specified format (MergedCells in my case) in
Cells range?


--

Dave Peterson

NOPIK

How to find cell with specific format?
 
Thanks, people. At the moment I use
Reslt=.Find "Context data"
if Reslt.MergeCells then SearchSucceed
so I wanted much safer way, than relate on user affected context
(search is in deep loop and I can't sacrifice speed to use walk by
range, anyway it perfomed, if context data not found in range).



All times are GMT +1. The time now is 07:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com