View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Scott Scott is offline
external usenet poster
 
Posts: 149
Default UnMerge Opened Workbook from Add-In

Below is a sub I have that unmerges any cells in the workbook. My problem is
that I now need this sub to exist in an add-in and run on any opened
worksheet (I'd prefer it to test if merged cells exist 1st, but not a
requirement). Ideally, it would iterate through all opened workbooks and run
on any sheets.

Given the fact that I'm not going to know the name of the workbook that will
have the merged cells and that I will be performing actions on from the sub
functions contained in the add-in, how can I force the below add-in sub to
unmerge cells on the opened workbook? Right now it gives an error when run
from Auto_Open() sub in the add-in. Error is "method cells of object _global
failed"


Sub UnMerge()

Cells.Select
With Selection
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With

End Sub