Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default variable for columns(??).property

With your help a while ago I was able to 'vary' the rows being procecessed.
the rows procedure works, I could not get the columns procedure to work.
sub variable_rows()
''' this works
Dim first, last, hiderange
first = 13
last = 15
hiderange = first & ":" & last
Rows(hiderange).Hidden = True
End Sub

Sub variable_columns()
'''this does not work, object error
Dim first, last, workrange
first = 13
last = 15
workrange = first & ":" & last
Columns(workrange).ColumnWidth = 20
End Sub

Help Please.
thanks.


--
Neal Z
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default variable for columns(??).property

Try this Neal

Sub variable_columns1()
Dim first As Integer, last As Integer
first = 13
last = 15
Range(Cells(1, first), Cells(1, last)).ColumnWidth = 20
End Sub

Or to hide

Sub variable_columns2()
Dim first As Integer, last As Integer
first = 13
last = 15
Range(Cells(1, first), Cells(1, last)).EntireColumn.Hidden = True
End Sub

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Neal Zimm" wrote in message ...
With your help a while ago I was able to 'vary' the rows being procecessed.
the rows procedure works, I could not get the columns procedure to work.
sub variable_rows()
''' this works
Dim first, last, hiderange
first = 13
last = 15
hiderange = first & ":" & last
Rows(hiderange).Hidden = True
End Sub

Sub variable_columns()
'''this does not work, object error
Dim first, last, workrange
first = 13
last = 15
workrange = first & ":" & last
Columns(workrange).ColumnWidth = 20
End Sub

Help Please.
thanks.


--
Neal Z



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default variable for columns(??).property

Of course, I use the range syntax a lot, just didn't think about these
properties.
thanks again,
Neal


"Ron de Bruin" wrote:

Try this Neal

Sub variable_columns1()
Dim first As Integer, last As Integer
first = 13
last = 15
Range(Cells(1, first), Cells(1, last)).ColumnWidth = 20
End Sub

Or to hide

Sub variable_columns2()
Dim first As Integer, last As Integer
first = 13
last = 15
Range(Cells(1, first), Cells(1, last)).EntireColumn.Hidden = True
End Sub

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Neal Zimm" wrote in message ...
With your help a while ago I was able to 'vary' the rows being procecessed.
the rows procedure works, I could not get the columns procedure to work.
sub variable_rows()
''' this works
Dim first, last, hiderange
first = 13
last = 15
hiderange = first & ":" & last
Rows(hiderange).Hidden = True
End Sub

Sub variable_columns()
'''this does not work, object error
Dim first, last, workrange
first = 13
last = 15
workrange = first & ":" & last
Columns(workrange).ColumnWidth = 20
End Sub

Help Please.
thanks.


--
Neal Z




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default variable for columns(??).property

Try:

first = "M"
last = "O"

BTW, you should declare the correct data types for your variables; i.e.:

Dim first As String, last As String, workrange As String

--

Vasant


--

Vasant



"Neal Zimm" wrote in message
...
With your help a while ago I was able to 'vary' the rows being

procecessed.
the rows procedure works, I could not get the columns procedure to work.
sub variable_rows()
''' this works
Dim first, last, hiderange
first = 13
last = 15
hiderange = first & ":" & last
Rows(hiderange).Hidden = True
End Sub

Sub variable_columns()
'''this does not work, object error
Dim first, last, workrange
first = 13
last = 15
workrange = first & ":" & last
Columns(workrange).ColumnWidth = 20
End Sub

Help Please.
thanks.


--
Neal Z



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default variable for columns(??).property

Thanks Vasant,
In my real code I dim the vars properly. For this example, since I use
option explicit I just dimmed them as varants for 'speed of typing'.
Also, because I use a lot of variables for columns and rows, i'm in the
habit of using the numbers rather than letters so I don't have to convert
a 1 into an "A".
Thanks again,
Neal


"Vasant Nanavati" wrote:

Try:

first = "M"
last = "O"

BTW, you should declare the correct data types for your variables; i.e.:

Dim first As String, last As String, workrange As String

--

Vasant


--

Vasant



"Neal Zimm" wrote in message
...
With your help a while ago I was able to 'vary' the rows being

procecessed.
the rows procedure works, I could not get the columns procedure to work.
sub variable_rows()
''' this works
Dim first, last, hiderange
first = 13
last = 15
hiderange = first & ":" & last
Rows(hiderange).Hidden = True
End Sub

Sub variable_columns()
'''this does not work, object error
Dim first, last, workrange
first = 13
last = 15
workrange = first & ":" & last
Columns(workrange).ColumnWidth = 20
End Sub

Help Please.
thanks.


--
Neal Z






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable Length Columns Gucktly Excel Discussion (Misc queries) 2 April 29th 10 07:32 PM
HLOOKUP using variable columns Chuka Excel Worksheet Functions 5 December 4th 08 11:40 PM
search columns, set variable value Robert Excel Programming 2 March 23rd 05 06:49 PM
Runtime error 380: Could not set the List property. invalid property value of listbox jasgrand Excel Programming 0 October 6th 04 09:28 PM
Is there a Filename property in PrintOut property Christian[_6_] Excel Programming 4 September 3rd 04 10:12 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"