Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have the following input data in an Excel spreadsheet(office 2007)
a1 b1 (a1 in cell A1, b1 in B2)
a2 b2 (a2 in cell A2, b2 in cell B2)is there a function that can group/link or tie the cells together as ''1 unit or block'' so that they can be copied, sorted etc.. as 1 block without losing their realtion. or that row or column insertion will not break or alter the block

First, you can't have b1 in B2 and b2 in B2, so I'll assume that's a typo.
Second, look at the Named Range feature.
Select A1:B2 and do one of the following:
1 - Just above cell A1 you should see a box that reads A1. It will typically show the upper left cell of the selected range.
Click in that box and enter a name, e.g. MyBlock. You have now created a Named Range called MyBlock that refers to A1:B2.
When you pull down the arrow next to that box, you can select MyBlock and it will highlight A1:B2 so you can work with it as a unit.
You can also select the Named Range by using Edit...Go to... and choosing MyBlock from the list.
2 - You can also create/edit/delete Named Ranges by using Insert...Name...Define.
Third - As far as preventing the insertion of rows and/or columns within a given Named Range, that's an interesting question.
You can Protect the sheet, giving users certain privileges, and you can Lock/Unlock cells within a protected sheet.
I'm thinking that some combination of sheet-level Protection, Locked cells and user privileges should get you what you want, but I'd need more specifics.
I don't know that you can prevent the insertions of a row within A1:B2 yet allow the insertion of a "row" between A3:B3, if you see what I mean. Depending on your needs, you may have to protect more than you really want.

Thanks for the tip, this helps alot in setting up the cell unit. It does not lock the cells as a unit as you can still drag one of the cells out of the unit and the others will not move with it, is there a fix to 'lock' the block so that the if you drag or move one cell all the cells in the block move with it ?

To address your specific question about moving an entire Named Range, you could use this Selection Change macro to have Excel select the entire Named Range if the user tries to select any cell within a named range.
This should also prevent the user from inserting rows or columns within the Named Range.
However, this method would prevent the editing of individual cells within the Named Range, since you can't select a single cell.
If that's going to be a problem, I'll once again ask for specifics as to what you want the users to be able to do as well as what they should not be able to do.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
For Each nm In ActiveWorkbook.Names
Set isect = Application.Intersect(Target, Range(nm))
If Not isect Is Nothing Then
Range(nm).Select
Exit For
End If
Next
End Sub

Hi,thanks again,unfortunately I have zero experience with macros . I could send you a small excel file thats shows exaclty the problem.

I've sent you an email address via PM. Send the file to that address along with a explanation of what you are trying to do.
I don't know of any way to "lock cells together" other than by using a macro, so you may need to learn a bit about VBA to accomplish your goal.
What doesn't kill you usually makes you stronger. As of yet, I haven't seen any reports of death-by-macro.

![]() |
OEM licence
|
Office Ultimate 2007 Key ...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |