ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   number of columns (https://www.excelbanter.com/excel-discussion-misc-queries/149347-number-columns.html)

ekkeindoha

number of columns
 
Good day,
I would like to know if it is possible to set a worksheet to only have let's
say columns A to G and 1 to 10

Niek Otten

number of columns
 
Not really, but you make it look like so.
FormatColumnHide, same for Rows

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"ekkeindoha" wrote in message ...
| Good day,
| I would like to know if it is possible to set a worksheet to only have let's
| say columns A to G and 1 to 10



Rick Rothstein \(MVP - VB\)

number of columns
 
I would like to know if it is possible to set a worksheet to only
have let's say columns A to G and 1 to 10


You could do this. Click on the H in column H's header to highlight the
entire column. Next, depress and hold down the Control and Shift keys...
while they are down, press the End key followed by the Right Arrow key. This
will select all the columns from column H to the end of the grid. Next,
click Format/Column/Hide from the Excel menu. Only columns A through G
should remain visible. Now, click the 11 in row 11's header, depress the
Control and Shift keys followed by the End key and Down Arrow key. Click
Format/Row/Hide and you should be left with what you asked for.

Rick


Dana DeLouis

number of columns
 
I would like to know if it is possible to set a worksheet to only have
let's
say columns A to G and 1 to 10


Another option might be to place code like this on the specific worksheet
module.
Maybe you can use some ideas he

Private Sub Worksheet_Activate()
Dim r As Long
Dim c As Long
Dim Nr As Long
Dim Nc As Long
Dim Rng As Range

Set Rng = [A1:G10]

r = Rng.Rows.Count
c = Rng.Columns.Count
Nr = Rows.Count
Nc = Columns.Count

ActiveSheet.Unprotect
ActiveSheet.ScrollArea = vbNullString ' ???
Rng.Locked = False 'Your Choice here ??

Rng.Rows(1).Offset(r).Resize(Nr - r).Hidden = True
Rng.Columns(1).Offset(, c).Resize(, Nc - c).Hidden = True

ActiveSheet.Protect
End Sub

--
Dana DeLouis



"ekkeindoha" wrote in message
...
Good day,
I would like to know if it is possible to set a worksheet to only have
let's
say columns A to G and 1 to 10




Gord Dibben

number of columns
 
You can hide what you don't want to see as others have pointed out.

You can also set the scrollarea to a fixed range.

Since the scrollarea method does not stick between sessions you will have to
reset it each time you open the workbook.

You may wish to place the code into a WorkBook_Open Sub in ThisWorkbook module
and specify which worksheet if only one sheet required.

Adjust the sheetname and range to suit.

Private Sub WorkBook_Open()
Sheets("YourSheet").ScrollArea = "A1:G10"
End Sub

Or also in the Thisworkbook module to limit scrollarea on all sheets.

Private Sub Workbook_SheetActivate(ByVal Sh As Object)
With ActiveSheet
.ScrollArea = "A1:G10"
End With
End Sub


Gord Dibben MS Excel MVP

On Sun, 8 Jul 2007 01:52:03 -0700, ekkeindoha
wrote:

Good day,
I would like to know if it is possible to set a worksheet to only have let's
say columns A to G and 1 to 10




All times are GMT +1. The time now is 11:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com