Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Restricting columns

Status
Not open for further replies.

DiscoP

Electrical
Nov 25, 2002
203
Does anyone know a way of limiting the number of columns in excel ?

The reason is that I make up spreadsheets and use names like (for example) CTR3 for cells.

We have recently moved to excel 2010, and there are more columns available so these are now cell references and can't be used as names.

I can use CTR_3, but I prefer retaining the name CTR3 if possible.

I am never going to need enough columns to require column CTR - so can I set up excel so that (say) AA is the highest column letter.
 
Replies continue below

Recommended for you

I'm pretty sure you can't do that. You can restrict the displayed range, but not the columns or rows that are allocated addresses.

I'd recommend going with the _, which is better practice anyway.

Doug Jenkins
Interactive Design Services
 
You can also place the _ at the beginning of the label and have _CTR3 which is the obviously a label and not a cell.
 
Hello,

this code can rename named ranges, not sure if it will work though.

Code:
Sub named_region()
    MY_SOURCE = InputBox("Enter Source Sheet Name")
    
    Sheets(MY_SOURCE).Range("AA1").Select
        With Selection.ListNames
            For MY_ROWS = 1 To Range(("AA") & Rows.Count).End(xlUp).Row
                MY_RANGE_NAME = "lbl" & Range("AA" & MY_ROWS).Value
                MY_ADDRESS = Mid(Range("AB" & MY_ROWS).Value, 2, Len(MY_SOURCE))
                MY_RANGE = Mid(Range("AB" & MY_ROWS).Value, Len(MY_SOURCE) + 3, Len(Range("AB" & MY_ROWS).Value))
                If Left(MY_ADDRESS, Len(MY_SOURCE) + 3) = MY_SOURCE Then
                    ActiveWorkbook.Names.Add Name:=MY_RANGE_NAME, RefersTo:="=" & MY_SOURCE & "!" & MY_RANGE
                    ActiveWorkbook.Names(Range("AA" & MY_ROWS).Value).Delete
                End If
            Next MY_ROWS
        End With
    Sheets(MY_SOURCE).Columns("AA:AB").ClearContents
End Sub

change AA & AB to available columns.

----------------------------------
Hope this helps.
----------------------------------

been away for quite a while
but am now back
 
I sympathize with you! I can remember moaning and complaining when we moved from 2003 to 2007.

But then the huge new vistas became apparent and the inconveniences were forgotten.

I hope you discover and leverage the ones that can make your life easier. I found that Structured Tables have tremendous potential, for instance.

Now here I'm making an assumption. If you have headings in a PRIMARY SOURCE data table of CTR1, CTR2, CTR3 etc, and using Named Ranges to do analysis, then you're doing that in the wrong place. You ought not to be using a non-normalized table for analysis! You should have a normalized table that includes a column like...
[pre]
Counter CntVal

CNT3 25
CNT6 312
CNT4 16
...
[/pre]
But I could be mistaken.

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor