Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Combined VBA line syntax

Being mostly self taught in VBA I tried to combine lines a and b into c,
using line d as an example from recording a macro.

compiler did not like line c.

How do you know when "combining" lines will work and when it will not?
thanks.

Cells(x, y).Borders(xlEdgeLeft).LineStyle = xlContinuous '' a
Cells(x, y).Borders(xlEdgeLeft).Weight = xlThick '' b

Cells(x, y).Borders(xlEdgeLeft) LineStyle:=xlContinuous, Weight:=xlThick '' c

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
'' d


--
Neal Z
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Combined VBA line syntax

LineStyle and Weight are two separate properties of the Border object. You
would select border in the Object browser and see if it had a method that
supported an argument for setting lineStyle and Weight.

As far as I know, there is no such method. the closest thing that does is
BorderAround, but that would put a border all the way around the cell and,
while it has LineStyle and Weight arguments the help says:

You can specify either LineStyle or Weight, but not both. If you don't
specify either argument, Microsoft Excel uses the default line style and
weight.

--
Regards,
Tom Ogilvy

"Neal Zimm" wrote in message
...
Being mostly self taught in VBA I tried to combine lines a and b into c,
using line d as an example from recording a macro.

compiler did not like line c.

How do you know when "combining" lines will work and when it will not?
thanks.

Cells(x, y).Borders(xlEdgeLeft).LineStyle = xlContinuous '' a
Cells(x, y).Borders(xlEdgeLeft).Weight = xlThick '' b

Cells(x, y).Borders(xlEdgeLeft) LineStyle:=xlContinuous, Weight:=xlThick

'' c

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
'' d


--
Neal Z



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Combined VBA line syntax

I think it's because .Linestyle and .Weight are properties that are set to
values, while .Protect is a method, which is like a subroutine that accepts
arguments. Someone more advanced please correct me if I'm mistaken!

"Neal Zimm" wrote:

Being mostly self taught in VBA I tried to combine lines a and b into c,
using line d as an example from recording a macro.

compiler did not like line c.

How do you know when "combining" lines will work and when it will not?
thanks.

Cells(x, y).Borders(xlEdgeLeft).LineStyle = xlContinuous '' a
Cells(x, y).Borders(xlEdgeLeft).Weight = xlThick '' b

Cells(x, y).Borders(xlEdgeLeft) LineStyle:=xlContinuous, Weight:=xlThick '' c

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
'' d


--
Neal Z

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Combined VBA line syntax

Let me be a little more explicit on the language syntax the compiler is
expecting. Properties are used to set or get values:

Object.Property = Value
Value = Object.Property

Methods are functions that are passed values as arguments

Object.Method Arg1, Arg2, Arg3, etc.
e.g.
Worksheet.Protect "ABC123", True, True

The arguments must be entered in the order the method is expecting them, and
missing (optional) arguments must have commas as placeholders (except for
missing arguments at the end.)

Object.Method Arg1, , Arg3, , Arg5

If you only want to supply specific arguments then you use the argument name
in the following syntax (and the order is not critical)

Worksheet.Protect Password:=€ABC123€, AllowFormattingCells:=True

In your example you removed the dot between

Cells(x, y).Borders(xlEdgeLeft)

and

LineStyle

Effectively telling the compiler you wanted to call an unnamed method using
two arguments, LineStyle and Weight

Cells(x, y).Borders(xlEdgeLeft) LineStyle:=xlContinuous, Weight:=xlThick
(no method name).....................^

Clear as mud?

"Charlie" wrote:

I think it's because .Linestyle and .Weight are properties that are set to
values, while .Protect is a method, which is like a subroutine that accepts
arguments. Someone more advanced please correct me if I'm mistaken!

"Neal Zimm" wrote:

Being mostly self taught in VBA I tried to combine lines a and b into c,
using line d as an example from recording a macro.

compiler did not like line c.

How do you know when "combining" lines will work and when it will not?
thanks.

Cells(x, y).Borders(xlEdgeLeft).LineStyle = xlContinuous '' a
Cells(x, y).Borders(xlEdgeLeft).Weight = xlThick '' b

Cells(x, y).Borders(xlEdgeLeft) LineStyle:=xlContinuous, Weight:=xlThick '' c

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
'' d


--
Neal Z

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Combined VBA line syntax

Thanks. will do. was just trying to save a little coding time.
Neal


"Tom Ogilvy" wrote:

LineStyle and Weight are two separate properties of the Border object. You
would select border in the Object browser and see if it had a method that
supported an argument for setting lineStyle and Weight.

As far as I know, there is no such method. the closest thing that does is
BorderAround, but that would put a border all the way around the cell and,
while it has LineStyle and Weight arguments the help says:

You can specify either LineStyle or Weight, but not both. If you don't
specify either argument, Microsoft Excel uses the default line style and
weight.

--
Regards,
Tom Ogilvy

"Neal Zimm" wrote in message
...
Being mostly self taught in VBA I tried to combine lines a and b into c,
using line d as an example from recording a macro.

compiler did not like line c.

How do you know when "combining" lines will work and when it will not?
thanks.

Cells(x, y).Borders(xlEdgeLeft).LineStyle = xlContinuous '' a
Cells(x, y).Borders(xlEdgeLeft).Weight = xlThick '' b

Cells(x, y).Borders(xlEdgeLeft) LineStyle:=xlContinuous, Weight:=xlThick

'' c

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
'' d


--
Neal Z






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 345
Default Combined VBA line syntax

Charlie -
Clearer than mud, sure. the 'method' terminology clears it up. I've
just got to learn more about that. I left the blank on purpose trying to
emulate the protection method without realizing the import of what I did.
Live and Learn.
thanks,
Neal


"Charlie" wrote:

Let me be a little more explicit on the language syntax the compiler is
expecting. Properties are used to set or get values:

Object.Property = Value
Value = Object.Property

Methods are functions that are passed values as arguments

Object.Method Arg1, Arg2, Arg3, etc.
e.g.
Worksheet.Protect "ABC123", True, True

The arguments must be entered in the order the method is expecting them, and
missing (optional) arguments must have commas as placeholders (except for
missing arguments at the end.)

Object.Method Arg1, , Arg3, , Arg5

If you only want to supply specific arguments then you use the argument name
in the following syntax (and the order is not critical)

Worksheet.Protect Password:=€ABC123€, AllowFormattingCells:=True

In your example you removed the dot between

Cells(x, y).Borders(xlEdgeLeft)

and

LineStyle

Effectively telling the compiler you wanted to call an unnamed method using
two arguments, LineStyle and Weight

Cells(x, y).Borders(xlEdgeLeft) LineStyle:=xlContinuous, Weight:=xlThick
(no method name).....................^

Clear as mud?

"Charlie" wrote:

I think it's because .Linestyle and .Weight are properties that are set to
values, while .Protect is a method, which is like a subroutine that accepts
arguments. Someone more advanced please correct me if I'm mistaken!

"Neal Zimm" wrote:

Being mostly self taught in VBA I tried to combine lines a and b into c,
using line d as an example from recording a macro.

compiler did not like line c.

How do you know when "combining" lines will work and when it will not?
thanks.

Cells(x, y).Borders(xlEdgeLeft).LineStyle = xlContinuous '' a
Cells(x, y).Borders(xlEdgeLeft).Weight = xlThick '' b

Cells(x, y).Borders(xlEdgeLeft) LineStyle:=xlContinuous, Weight:=xlThick '' c

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
'' d


--
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
Combined bar/Line graph defaults to bar Michael Anderson Charts and Charting in Excel 1 November 29th 07 01:20 PM
scatter and line combined Ray Pendergast Charts and Charting in Excel 3 August 17th 07 01:53 AM
combined line-column excel chart Francisco Barros Castro Charts and Charting in Excel 1 September 22nd 06 11:17 AM
combined scatter plot and line data bmayers Excel Discussion (Misc queries) 2 June 25th 06 06:11 PM
Combined line/stacked column chart Red Charts and Charting in Excel 2 September 13th 05 03:43 AM


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

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

About Us

"It's about Microsoft Excel"