visual basic Loop by rows in Excel

  • Thread starter Thread starter Carrie_Loos via OfficeKB.com
  • Start date Start date
C

Carrie_Loos via OfficeKB.com

I have a data range with merged cells and other cells not merged in a
spreadsheet. I want to find only the merged cells so I can store a lookup
function in them using visual basic. My problem is I can't figure out either
how to enter the function in the merged cells only and stop the loop so it
doesn't go into my titles, which are merged cells, and enter the function in
those. Any ideas?

Thanks
 
I, among many, do not believe in merged cells but assuming your titles in
row 1, try this

Sub findmergedcells()
For Each c In Range("e2:e22")
If c.MergeCells = True Then MsgBox c.Row
Next
End Sub
 
Thanks - works great

Don said:
I, among many, do not believe in merged cells but assuming your titles in
row 1, try this

Sub findmergedcells()
For Each c In Range("e2:e22")
If c.MergeCells = True Then MsgBox c.Row
Next
End Sub
I have a data range with merged cells and other cells not merged in a
spreadsheet. I want to find only the merged cells so I can store a lookup
[quoted text clipped - 6 lines]
 
Glad to help

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
Carrie_Loos via OfficeKB.com said:
Thanks - works great

Don said:
I, among many, do not believe in merged cells but assuming your titles in
row 1, try this

Sub findmergedcells()
For Each c In Range("e2:e22")
If c.MergeCells = True Then MsgBox c.Row
Next
End Sub
I have a data range with merged cells and other cells not merged in a
spreadsheet. I want to find only the merged cells so I can store a
lookup
[quoted text clipped - 6 lines]
 

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

Back
Top