Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Automatic Borders

Hi,

I have 55 workbooks and all need to be formatted exactly the same, but have
different ammounts of data. The First line of data is at Row 10 and I need
a border every 4 rows after Row 10 until the end. The total number of rows
is not necessarily a multiple of 4, so at the data at the end may only be 3
rows, and the border needs to be after the last row. How can I accomplish
this?

Thanks,

Mike

10
-------- border
11
12
13
14
-------- border
15
16
17
18
-------- border
19
-------- border


  #2   Report Post  
Posted to microsoft.public.excel.programming
Ben Ben is offline
external usenet poster
 
Posts: 509
Default Automatic Borders

i know no one here likes loops but i'm not smart enough to not use them


j = 10
startdo:
if cells(j,1).value = "" then
range(cells(j-1,1),cells(j-1,"put number of columns you want to border
here").borders(edgebottom).linestyle = xlcontinuous
exit sub
end if
k = j - 10
if k/4 < int(k/4) then goto skip
range(cells(j,1),cells(j,"put number of columns you want to border
here").borders(edgebottom).linestyle = xlcontinuous
skip:
j=j+1
goto startdo


"Reed" wrote:

Hi,

I have 55 workbooks and all need to be formatted exactly the same, but have
different ammounts of data. The First line of data is at Row 10 and I need
a border every 4 rows after Row 10 until the end. The total number of rows
is not necessarily a multiple of 4, so at the data at the end may only be 3
rows, and the border needs to be after the last row. How can I accomplish
this?

Thanks,

Mike

10
-------- border
11
12
13
14
-------- border
15
16
17
18
-------- border
19
-------- border



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Automatic Borders

Reed, try something like this. You will need to modify the columns and
border attributes to suite your needs:

Option Explicit
Sub autoBorders()
Dim cntRows&, X&
cntRows = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For X = 10 To cntRows - 1 Step 4
'This example assumes the border
'is to be in columns A to D
'beginning in row 10.
Range(Cells(X, 1), Cells(X, 4)).Select
With Selection.Borders(xlEdgeBottom)
..LineStyle = xlContinuous
..Weight = xlThin
..ColorIndex = xlAutomatic
End With
Next X
Range(Cells(cntRows, 1), Cells(cntRows, 4)).Select
With Selection.Borders(xlEdgeBottom)
..LineStyle = xlContinuous
..Weight = xlThin
..ColorIndex = xlAutomatic
End With
End Sub

Regards--Lonnie M.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Automatic Borders

Worked Great. You are a Genius! Thanks!


"Lonnie M." wrote in message
oups.com...
Reed, try something like this. You will need to modify the columns and
border attributes to suite your needs:

Option Explicit
Sub autoBorders()
Dim cntRows&, X&
cntRows = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For X = 10 To cntRows - 1 Step 4
'This example assumes the border
'is to be in columns A to D
'beginning in row 10.
Range(Cells(X, 1), Cells(X, 4)).Select
With Selection.Borders(xlEdgeBottom)
..LineStyle = xlContinuous
..Weight = xlThin
..ColorIndex = xlAutomatic
End With
Next X
Range(Cells(cntRows, 1), Cells(cntRows, 4)).Select
With Selection.Borders(xlEdgeBottom)
..LineStyle = xlContinuous
..Weight = xlThin
..ColorIndex = xlAutomatic
End With
End Sub

Regards--Lonnie M.


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
borders mhenley5 Excel Discussion (Misc queries) 2 May 5th 09 11:09 PM
Borders Derek Koehler Excel Discussion (Misc queries) 1 March 12th 09 02:19 PM
Borders anita Excel Worksheet Functions 6 September 15th 06 01:15 PM
borders Brush Prairie Excel Discussion (Misc queries) 0 August 23rd 05 02:57 AM
Borders Alan Excel Programming 3 November 10th 04 06:40 PM


All times are GMT +1. The time now is 10:06 AM.

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"