Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Arguments as properties

I'm sure I'm doing this wrong, but I'm trying to use an
argument (variable) as a property:

Sub Test1()
ob1 = InputBox("Border: thin (1) or thick (2): ")
If ob1 = 1 Then ob1 = "xlThin"
If ob1 = 2 Then ob1 = "xlThick"
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = ob1
.ColorIndex = 1
End With
End Sub

I've used a MsgBox to confirm that ob1 is indeed set to
xlThick or xlThin, but I get run time error 1004 Unable
to set Weight property of the Border class.

Am I making a simple syntax error, or is this approach
not possible? Any help most greatfully appreciated!


BruceD
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Arguments as properties

Bruce,

Get rid of the quotes around xlThin and xlThick.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"BruceD" wrote in message
...
I'm sure I'm doing this wrong, but I'm trying to use an
argument (variable) as a property:

Sub Test1()
ob1 = InputBox("Border: thin (1) or thick (2): ")
If ob1 = 1 Then ob1 = "xlThin"
If ob1 = 2 Then ob1 = "xlThick"
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = ob1
.ColorIndex = 1
End With
End Sub

I've used a MsgBox to confirm that ob1 is indeed set to
xlThick or xlThin, but I get run time error 1004 Unable
to set Weight property of the Border class.

Am I making a simple syntax error, or is this approach
not possible? Any help most greatfully appreciated!


BruceD



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Arguments as properties

Thanks to all who thought about this and answered!

Chip was right: getting rid of the quotes solved the
problem.

Bruce
-----Original Message-----
Bruce,

Get rid of the quotes around xlThin and xlThick.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"BruceD" wrote in

message
...
I'm sure I'm doing this wrong, but I'm trying to use an
argument (variable) as a property:

Sub Test1()
ob1 = InputBox("Border: thin (1) or thick (2): ")
If ob1 = 1 Then ob1 = "xlThin"
If ob1 = 2 Then ob1 = "xlThick"
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = ob1
.ColorIndex = 1
End With
End Sub

I've used a MsgBox to confirm that ob1 is indeed set to
xlThick or xlThin, but I get run time error 1004 Unable
to set Weight property of the Border class.

Am I making a simple syntax error, or is this approach
not possible? Any help most greatfully appreciated!


BruceD



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
ijb ijb is offline
external usenet poster
 
Posts: 26
Default Arguments as properties

Try:

Sub Test1()
ob1 = InputBox("Border: thin (1) or thick (2): ")
If ob1 = 1 Then ob1 = xlThin
If ob1 = 2 Then ob1 = xlThick
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = ob1
.ColorIndex = 1
End With
End Sub

--
If I've mis-understood the question please tell me.

HTH

ijb

Replies to group please

Not MCSD, MVP, TLA, P&P, PCMCIA, etc just trying to help


"BruceD" wrote in message
...
I'm sure I'm doing this wrong, but I'm trying to use an
argument (variable) as a property:

Sub Test1()
ob1 = InputBox("Border: thin (1) or thick (2): ")
If ob1 = 1 Then ob1 = "xlThin"
If ob1 = 2 Then ob1 = "xlThick"
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = ob1
.ColorIndex = 1
End With
End Sub

I've used a MsgBox to confirm that ob1 is indeed set to
xlThick or xlThin, but I get run time error 1004 Unable
to set Weight property of the Border class.

Am I making a simple syntax error, or is this approach
not possible? Any help most greatfully appreciated!


BruceD



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default Arguments as properties

Just to add to the others. In Excel XP, xlThin has a value of 2, so you may
want to change your logic.

?xlThin
2

One of a few ways:

If ob1 = 1 Then
ob1 = "xlThin"
ElseIf ob1 = 2 Then
ob1 = "xlThick"
Else
' ??
End If


HTH
Dana DeLouis


"BruceD" wrote in message
...
I'm sure I'm doing this wrong, but I'm trying to use an
argument (variable) as a property:

Sub Test1()
ob1 = InputBox("Border: thin (1) or thick (2): ")
If ob1 = 1 Then ob1 = "xlThin"
If ob1 = 2 Then ob1 = "xlThick"
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = ob1
.ColorIndex = 1
End With
End Sub

I've used a MsgBox to confirm that ob1 is indeed set to
xlThick or xlThin, but I get run time error 1004 Unable
to set Weight property of the Border class.

Am I making a simple syntax error, or is this approach
not possible? Any help most greatfully appreciated!


BruceD





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
Too few arguments plore Excel Worksheet Functions 5 July 19th 12 02:36 PM
Too many arguments Nick Wakeham Excel Worksheet Functions 2 March 18th 09 06:19 PM
IF-more than 7 arguments Carolina Excel Discussion (Misc queries) 3 May 20th 08 10:38 PM
arguments gemini0662 Excel Discussion (Misc queries) 9 July 13th 06 03:48 PM
How Many Arguments? Jerry W. Lewis Excel Programming 4 November 3rd 03 01:25 PM


All times are GMT +1. The time now is 03:32 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"