Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default I need a macro for inserting a border line every 20 rows

I need a macro for inserting a border line every 20 rows. i have tried to
record this, but I went wrong. Very wrong. It's a bottom border line. (I
posted this before, but now I cannot find it). Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,533
Default I need a macro for inserting a border line every 20 rows

Try this:

Sub InsertBorderline()
StartLine = 20
EndLine = 100

For r = StartLine To EndLine Step 20
With Rows(r).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Next
End Sub

Regards,
Per

"Adamp" skrev i meddelelsen
...
I need a macro for inserting a border line every 20 rows. i have tried to
record this, but I went wrong. Very wrong. It's a bottom border line.
(I
posted this before, but now I cannot find it). Thanks


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default I need a macro for inserting a border line every 20 rows

I'm not sure what is the first row to get the border or what columns should get
the border, but this may give you a start:

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim EveryXRows As Long
Dim RngToGetBorder As Range

Set wks = Worksheets("sheet1")
EveryXRows = 20

With wks
Set RngToGetBorder = .Range("A:E")
FirstRow = 20

With .UsedRange
LastRow = .Cells(.Cells.Count).Row
End With

For iRow = FirstRow To LastRow Step EveryXRows
With Intersect(.Rows(iRow), RngToGetBorder)
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With
Next iRow
End With
End Sub

And if you're looking for old posts:

You can use google (maybe a few hours behind) to search for stuff you've posted
(and find the replies, too)

http://groups.google.com/advanced_group_search
http://groups.google.com/advanced_gr...Excel*&num=100

Ron de Bruin has an excel addin that you may like:
http://www.rondebruin.nl/Google.htm

Adamp wrote:

I need a macro for inserting a border line every 20 rows. i have tried to
record this, but I went wrong. Very wrong. It's a bottom border line. (I
posted this before, but now I cannot find it). Thanks


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default I need a macro for inserting a border line every 20 rows

Cleaned up from recorded macro below
Sub bottombordermod()
For i = 1 To 100 Step 20
Rows(i).Borders(xlEdgeBottom).LineStyle = xlContinuous
Next i
End Sub

Sub Macro10()
'
' Macro10 Macro
' Macro recorded 8/20/2008 by Donald B. Guillett
'

'
Rows("16:16").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
End Sub
Sub bottombordermod()
For i = 1 To 50 Step 10
Rows(i).Borders(xlEdgeBottom).LineStyle = xlContinuous
Next i
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Adamp" wrote in message
...
I need a macro for inserting a border line every 20 rows. i have tried to
record this, but I went wrong. Very wrong. It's a bottom border line.
(I
posted this before, but now I cannot find it). Thanks


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default I need a macro for inserting a border line every 20 rows

Is there a way to get the wks variable to change to the active worksheet?
This is quite helpful even if this cannot be done.
--
Thanks,

Adam P


"Dave Peterson" wrote:

I'm not sure what is the first row to get the border or what columns should get
the border, but this may give you a start:

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim EveryXRows As Long
Dim RngToGetBorder As Range

Set wks = Worksheets("sheet1")
EveryXRows = 20

With wks
Set RngToGetBorder = .Range("A:E")
FirstRow = 20

With .UsedRange
LastRow = .Cells(.Cells.Count).Row
End With

For iRow = FirstRow To LastRow Step EveryXRows
With Intersect(.Rows(iRow), RngToGetBorder)
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With
Next iRow
End With
End Sub

And if you're looking for old posts:

You can use google (maybe a few hours behind) to search for stuff you've posted
(and find the replies, too)

http://groups.google.com/advanced_group_search
http://groups.google.com/advanced_gr...Excel*&num=100

Ron de Bruin has an excel addin that you may like:
http://www.rondebruin.nl/Google.htm

Adamp wrote:

I need a macro for inserting a border line every 20 rows. i have tried to
record this, but I went wrong. Very wrong. It's a bottom border line. (I
posted this before, but now I cannot find it). Thanks


--

Dave Peterson



  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default I need a macro for inserting a border line every 20 rows

Set wks = Activesheet

Adamp wrote:

Is there a way to get the wks variable to change to the active worksheet?
This is quite helpful even if this cannot be done.
--
Thanks,

Adam P

"Dave Peterson" wrote:

I'm not sure what is the first row to get the border or what columns should get
the border, but this may give you a start:

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim EveryXRows As Long
Dim RngToGetBorder As Range

Set wks = Worksheets("sheet1")
EveryXRows = 20

With wks
Set RngToGetBorder = .Range("A:E")
FirstRow = 20

With .UsedRange
LastRow = .Cells(.Cells.Count).Row
End With

For iRow = FirstRow To LastRow Step EveryXRows
With Intersect(.Rows(iRow), RngToGetBorder)
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With
Next iRow
End With
End Sub

And if you're looking for old posts:

You can use google (maybe a few hours behind) to search for stuff you've posted
(and find the replies, too)

http://groups.google.com/advanced_group_search
http://groups.google.com/advanced_gr...Excel*&num=100

Ron de Bruin has an excel addin that you may like:
http://www.rondebruin.nl/Google.htm

Adamp wrote:

I need a macro for inserting a border line every 20 rows. i have tried to
record this, but I went wrong. Very wrong. It's a bottom border line. (I
posted this before, but now I cannot find it). Thanks


--

Dave Peterson


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,081
Default I need a macro for inserting a border line every 20 rows

simply change

Set wks = Worksheets("sheet1")

to

Set wks = activesheet

"Adamp" wrote:

Is there a way to get the wks variable to change to the active worksheet?
This is quite helpful even if this cannot be done.
--
Thanks,

Adam P


"Dave Peterson" wrote:

I'm not sure what is the first row to get the border or what columns should get
the border, but this may give you a start:

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim EveryXRows As Long
Dim RngToGetBorder As Range

Set wks = Worksheets("sheet1")
EveryXRows = 20

With wks
Set RngToGetBorder = .Range("A:E")
FirstRow = 20

With .UsedRange
LastRow = .Cells(.Cells.Count).Row
End With

For iRow = FirstRow To LastRow Step EveryXRows
With Intersect(.Rows(iRow), RngToGetBorder)
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With
Next iRow
End With
End Sub

And if you're looking for old posts:

You can use google (maybe a few hours behind) to search for stuff you've posted
(and find the replies, too)

http://groups.google.com/advanced_group_search
http://groups.google.com/advanced_gr...Excel*&num=100

Ron de Bruin has an excel addin that you may like:
http://www.rondebruin.nl/Google.htm

Adamp wrote:

I need a macro for inserting a border line every 20 rows. i have tried to
record this, but I went wrong. Very wrong. It's a bottom border line. (I
posted this before, but now I cannot find it). Thanks


--

Dave Peterson

  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default I need a macro for inserting a border line every 20 rows

That was too easy. Thanks!! Works like a charm. All I did was change it
from column E to Z.
--
Thanks,

Adam P


"Dave Peterson" wrote:

Set wks = Activesheet

Adamp wrote:

Is there a way to get the wks variable to change to the active worksheet?
This is quite helpful even if this cannot be done.
--
Thanks,

Adam P

"Dave Peterson" wrote:

I'm not sure what is the first row to get the border or what columns should get
the border, but this may give you a start:

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim EveryXRows As Long
Dim RngToGetBorder As Range

Set wks = Worksheets("sheet1")
EveryXRows = 20

With wks
Set RngToGetBorder = .Range("A:E")
FirstRow = 20

With .UsedRange
LastRow = .Cells(.Cells.Count).Row
End With

For iRow = FirstRow To LastRow Step EveryXRows
With Intersect(.Rows(iRow), RngToGetBorder)
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With
Next iRow
End With
End Sub

And if you're looking for old posts:

You can use google (maybe a few hours behind) to search for stuff you've posted
(and find the replies, too)

http://groups.google.com/advanced_group_search
http://groups.google.com/advanced_gr...Excel*&num=100

Ron de Bruin has an excel addin that you may like:
http://www.rondebruin.nl/Google.htm

Adamp wrote:

I need a macro for inserting a border line every 20 rows. i have tried to
record this, but I went wrong. Very wrong. It's a bottom border line. (I
posted this before, but now I cannot find it). Thanks

--

Dave Peterson


--

Dave Peterson

  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default I need a macro for inserting a border line every 20 rows

Gee, I guess my offering was just sooooooooo short.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Adamp" wrote in message
...
That was too easy. Thanks!! Works like a charm. All I did was change it
from column E to Z.
--
Thanks,

Adam P


"Dave Peterson" wrote:

Set wks = Activesheet

Adamp wrote:

Is there a way to get the wks variable to change to the active
worksheet?
This is quite helpful even if this cannot be done.
--
Thanks,

Adam P

"Dave Peterson" wrote:

I'm not sure what is the first row to get the border or what columns
should get
the border, but this may give you a start:

Option Explicit
Sub testme()

Dim wks As Worksheet
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
Dim EveryXRows As Long
Dim RngToGetBorder As Range

Set wks = Worksheets("sheet1")
EveryXRows = 20

With wks
Set RngToGetBorder = .Range("A:E")
FirstRow = 20

With .UsedRange
LastRow = .Cells(.Cells.Count).Row
End With

For iRow = FirstRow To LastRow Step EveryXRows
With Intersect(.Rows(iRow), RngToGetBorder)
With .Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With
Next iRow
End With
End Sub

And if you're looking for old posts:

You can use google (maybe a few hours behind) to search for stuff
you've posted
(and find the replies, too)

http://groups.google.com/advanced_group_search
http://groups.google.com/advanced_gr...Excel*&num=100

Ron de Bruin has an excel addin that you may like:
http://www.rondebruin.nl/Google.htm

Adamp wrote:

I need a macro for inserting a border line every 20 rows. i have
tried to
record this, but I went wrong. Very wrong. It's a bottom border
line. (I
posted this before, but now I cannot find it). Thanks

--

Dave Peterson


--

Dave Peterson


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
Macro Help- Inserting Blank Rows jack Excel Discussion (Misc queries) 3 January 16th 07 09:43 PM
Macro needed for inserting blank rows sunslight Excel Worksheet Functions 2 January 12th 07 05:58 PM
INserting Specific Number of Rows via macro [email protected] Links and Linking in Excel 1 November 14th 06 09:56 PM
10 000 Line, every 2 Lines need a border and a open line inbet. e. annalie Excel Discussion (Misc queries) 2 January 30th 06 03:15 PM
Inserting Blank Rows Macro? Michael Saffer Excel Worksheet Functions 2 November 9th 04 06:23 PM


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