ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Width of ActiveCell (https://www.excelbanter.com/excel-programming/360278-width-activecell.html)

EXCEL NEWS

Width of ActiveCell
 

hi,

could you tell what is wrong with my sub

Sub lw()
ActiveCell.CurrentRegion.Width
End Sub

thanks



Gary Keramidas

Width of ActiveCell
 
try this

Sub lw()
Dim p As Double
p = ActiveCell.Columns.ColumnWidth
MsgBox p
End Sub


--


Gary


"EXCEL NEWS" wrote in message
...

hi,

could you tell what is wrong with my sub

Sub lw()
ActiveCell.CurrentRegion.Width
End Sub

thanks





Ardus Petus

Width of ActiveCell
 
Your Sub does nothing.
It references Width property (in points) of current region.

In order to have it return a value, you must turn it into a Function

Function lw() as Long
lw = ActiveCell.CurrentRegion.Width
End Function

Now you can use your Function from within a cell or another Sub/Function.

HTH
--
AP


"EXCEL NEWS" a ecrit dans le message de news:
...

hi,

could you tell what is wrong with my sub

Sub lw()
ActiveCell.CurrentRegion.Width
End Sub

thanks





AA2e72E

Width of ActiveCell
 
Lookup STRCONV in the help files.



EXCEL NEWS

Width of ActiveCell
 
thanks a lot,

the sub is ok,

you neednot change it to fun,



"Ardus Petus" wrote in message
...
Your Sub does nothing.
It references Width property (in points) of current region.

In order to have it return a value, you must turn it into a Function

Function lw() as Long
lw = ActiveCell.CurrentRegion.Width
End Function

Now you can use your Function from within a cell or another Sub/Function.

HTH
--
AP


"EXCEL NEWS" a ecrit dans le message de news:
...

hi,

could you tell what is wrong with my sub

Sub lw()
ActiveCell.CurrentRegion.Width
End Sub

thanks






Bob Phillips[_6_]

Width of ActiveCell
 

"EXCEL NEWS" wrote in message
...

the sub is ok,

you neednot change it to fun,


It is not it is not runnable as it stands. What are you attempting to do?




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

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