It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

help with VB in Excel

Moderator: dafunkymunky

help with VB in Excel

Postby thompson9100 on Tue Jan 22, 2008 9:37 am

Hi

Trying to auto-format a report using a macro, but I don't know enough code to do it!

I've got the macro set up, but I need to alter it so that it finds Total then puts a border on 7 colums in that row.

How can I reference the row that FIND has located to transfer it to a cell reference (ie so I don't just have "$A$1".

Also, I think I use FindNext to repeat this but how can I stop it once it's done all that it's found from top to bottom?

The code is below, many thanks in anticipation.

Sub InsertLine()
'
' InsertLine Macro
' Macro recorded 16/01/2008 by BMW (GB) Limited This macro will insert a line below each WIP.
'
' Keyboard Shortcut: Ctrl+Shift+R
'

MyRow = Cells.Find(What:="total", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
MsgBox MyRow
Range("A:E").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlEdgeTop).LineStyle = xlNone
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End Sub
thompson9100
 
Posts: 0
Joined: Tue Jan 22, 2008 9:31 am
Location: Worcester, UK

Who is online

Users browsing this forum: No registered users and 3 guests