Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > Drawing lines to cells with VBA


Reply
 
Thread Tools Display Modes
  #1  
Old 06-30-2005, 10:00 AM
Werner Werner is offline
Regular
 
Join Date: Jun 2005
Location: Canada
Posts: 67
Question Drawing lines to cells with VBA


Hi,

I have a couple of rows (which change in numbers of rows when I use another macro) and I want to put a double line at the bottom of the last row. I used the recorder to find the beginning of my code and then I modified it for my specific needs. But it says that the method Range of the object '_Global' failed. I need my line to be drawn from colomn A to AE. Does anyone see where is the problem in my code?
Thx!

Werner

Quote:

Sub Draw_Double_Line()

'Line that find the number of rows.
Let lstRw = Sheets("Formulaire").Range("a65536").End(xlUp).Row

With Worksheets("Formulaire")
Range("A:AE" & lstRw).Borders(xlDiagonalDown).LineStyle = xlNone
Range("A:AE" & lstRw).Borders(xlDiagonalUp).LineStyle = xlNone
Range("A:AE" & lstRw).Borders(xlEdgeLeft).LineStyle = xlNone
Range("A:AE" & lstRw).Borders(xlEdgeTop).LineStyle = xlNone
With Range("A:AE" & lstRw).Borders(xlEdgeBottom)
.LineStyle = xlDouble
.Weight = xlThick
.ColorIndex = 1
End With
Range("A:AE" & lstRw).Borders(xlEdgeRight).LineStyle = xlNone

End With

End Sub
Reply With Quote
  #2  
Old 06-30-2005, 12:12 PM
Werner Werner is offline
Regular
 
Join Date: Jun 2005
Location: Canada
Posts: 67
Default

Folks from another forum helped me out on that one. The fix is :

Quote:

Code:

Range("A" & lstRw & ":AE" & lstRw)
Reply With Quote
  #3  
Old 07-05-2005, 08:48 AM
xtraBilly's Avatar
xtraBilly xtraBilly is offline
Centurion
 
Join Date: Mar 2002
Location: Brooklyn,New York
Posts: 140
Default

Looks like you left out the "." before "Range" & you missed putting in the starting point of the range

.Range("A1:AE" & lstRw).Borders(xlDiagonalDown).LineStyle = xlNone
Reply With Quote
  #4  
Old 07-05-2005, 11:10 AM
Werner Werner is offline
Regular
 
Join Date: Jun 2005
Location: Canada
Posts: 67
Default

A & lstRw is the starting point. lstRw is a variable that tells me if my line will be drawn from colomn A (for example 16) to AE16 or A203 to AE203. The line is drawn on a row. To resume, the starting and ending points are both dynamic.

I forgot to add this line to the With Worksheets. I'll fix that.

Thx for your help

Werner
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->