LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Restore formats in merged cells ...

Hi,

I have a O.K. routine today that restore format when merged cells are the
target in a worksheet_change event. The code is like below - for testing
merge cells A1:D1 and forward to row 10.

Now I need to restore format by button and need to change the routine to
work with all merged cells from A1:D1 to A10:D10. How can I do that - I've
tried a while now but can't get the procedure right. Please help. Manybe
your solution can handle the last two inhibited row to unlock cells and
unhide them ...:? The button connection is not a probelm -the probelm is to
reference the merged cells, make the object right, to take them one by one
in a loop or...?


(To test routine: Merge cells A1:D1 and forward to row 10)

Private Sub Worksheet_Change(ByVal Target As Range)
'****** Restore merged cells format by change ************

If Not Application.Intersect(Target, Sheet1.Range("A1:D10")) Is Nothing Then
Target.NumberFormat = "@"
With Target
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
With Target.Font
.Name = "Arial"
.FontStyle = "Normal"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
End With

' ----------Need borders around mergedcells, not within their cells
Dim sel As Range
Set sel = Sheet1.Range(Cells(Target.Row, Target.Column),
Cells(Target.Row, Target.Column + 3))

sel.Borders(xlDiagonalDown).LineStyle = xlNone
sel.Borders(xlDiagonalUp).LineStyle = xlNone
With sel.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 1
End With
With sel.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 37
End With
With sel.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 37
End With
With sel.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 1
End With
sel.Borders(xlInsideVertical).LineStyle = xlNone
With Target.Interior
.ColorIndex = 36
.Pattern = xlSolid
.PatternColorIndex = 10
End With

sel.FormatConditions.Delete

'sel.Locked = False
'sel.FormulaHidden = False

End If

End Sub


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy paste non merged to merged cells [email protected] Excel Worksheet Functions 1 February 5th 09 05:25 PM
How to restore color formats to spreadsheets in Excel 2003? Love / Hate Excel Excel Discussion (Misc queries) 1 January 23rd 09 10:32 PM
Autofit Merged cell Code is changing the format of my merged cells JB Excel Discussion (Misc queries) 0 August 20th 07 02:12 PM
how do i link merged cells to a merged cell in another worksheet. ibbm Excel Worksheet Functions 3 April 27th 06 11:40 PM
Sorting merged cellsHow do I sort merged cells not identically siz Laval Excel Worksheet Functions 1 November 3rd 04 09:40 PM


All times are GMT +1. The time now is 02:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"