ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   columns seletion error (https://www.excelbanter.com/excel-programming/291109-columns-seletion-error.html)

Mark Kubicki

columns seletion error
 
i have this code entered:

Public Function PayRollSheetFormat()
'Application.Run CleanSheetFormat()
ActiveWindow.FreezePanes = False
Columns("S:S").Select
Selection.ColumnWidth = 10
Columns("T:T").Select
Selection.ColumnWidth = 25
End Function

selecting column S or T selects multiple columns (usually 4: R,S,T,U or
S,T,U,V respectively)

any hints about what might be causing the error?

mark



Frank Kabel

columns seletion error
 
Hi Mark
some ideas:
- the .select is not required.
- why are you using a function. This won't work as functions can not
change the width of cells - use a sub

try the following
Public Sub PayRollSheetFormat()
'Application.Run CleanSheetFormat()
ActiveWindow.FreezePanes = False
Columns("S").ColumnWidth = 10
Columns("T").ColumnWidth = 25
End Sub

Frank

Try the following:
Public Function PayRollSheetFormat()
'Application.Run CleanSheetFormat()
ActiveWindow.FreezePanes = False
Columns("S:S").Select
Selection.ColumnWidth = 10
Columns("T:T").Select
Selection.ColumnWidth = 25
End Function



mark kubicki wrote:
i have this code entered:

Public Function PayRollSheetFormat()
'Application.Run CleanSheetFormat()
ActiveWindow.FreezePanes = False
Columns("S:S").Select
Selection.ColumnWidth = 10
Columns("T:T").Select
Selection.ColumnWidth = 25
End Function

selecting column S or T selects multiple columns (usually 4: R,S,T,U
or S,T,U,V respectively)

any hints about what might be causing the error?

mark





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

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