Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Merge consecutive cells using conditional formatting.

Here is what I was looking for

Suppose Cell B1= 2 , then I wanted to cells C1 and D1 to be blank and
locked ( Locked in the sence, no one should be able to write in those
cell. They should be as good as merged cell where I can't even blink my
cursor)

So depending on the values of the cell in column B, I wanted to make
the equivalenmt cells in that row as dead locked.
Suppose B1 = 3 then C1 D1 and E1 should be dead locked.
Suppose B2 = 4 then C2, D2, E2 and F2 should be dead locked.

Dead locked means no one should be able to write in nor format those
cell.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Merge consecutive cells using conditional formatting.

Sub SetCells()
ActiveSheet.Unprotect Password:="ABC"
Set rng = Range(Cells(1, 2), Cells(Rows.Count, 2).End(xlUp))
For Each cell In rng
If IsNumeric(cell.Value) Then
cell.Resize(1, cell.Value).Locked = True
End If
Next
ActiveSheet.EnableSelection = xlUnlockedCells
ActiveSheet.Protect Password:="ABC"
End Sub

the default state for cells is locked, so if you want all other cells
selectable

Sub SetCells()
ActiveSheet.Unprotect Password:="ABC"
Cells.Locked = false
Set rng = Range(Cells(1, 2), Cells(Rows.Count, 2).End(xlUp))
For Each cell In rng
If IsNumeric(cell.Value) Then
cell.Resize(1, cell.Value).Locked = True
End If
Next
ActiveSheet.EnableSelection = xlUnlockedCells
ActiveSheet.Protect Password:="ABC"
End Sub

--
Regards,
Tom Ogilvy



wrote in message
ps.com...
Here is what I was looking for

Suppose Cell B1= 2 , then I wanted to cells C1 and D1 to be blank and
locked ( Locked in the sence, no one should be able to write in those
cell. They should be as good as merged cell where I can't even blink my
cursor)

So depending on the values of the cell in column B, I wanted to make
the equivalenmt cells in that row as dead locked.
Suppose B1 = 3 then C1 D1 and E1 should be dead locked.
Suppose B2 = 4 then C2, D2, E2 and F2 should be dead locked.

Dead locked means no one should be able to write in nor format those
cell.



Reply
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
Excel +won't +merge cells in a column. Is my formatting blocking . Blue Heeler1 New Users to Excel 4 January 5th 09 04:06 AM
Excel 2007 conditional format and merge cells PeterHS Excel Discussion (Misc queries) 0 June 17th 08 04:41 PM
Conditional formatting with multiple, non-consecutive values?? David in VB Excel Discussion (Misc queries) 8 January 6th 08 01:05 AM
conditional formatting consecutive cells chris Excel Worksheet Functions 7 May 9th 07 09:41 PM
Conditional formatting on Consecutive cells welshobit Excel Worksheet Functions 4 June 20th 06 03:58 PM


All times are GMT +1. The time now is 10:37 AM.

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"