Thread
:
Formatting via a macro
View Single Post
#
3
Posted to microsoft.public.excel.misc
Don Guillett
external usenet poster
Posts: 10,124
Formatting via a macro
try this
Sub formatfoundcells()
findwhat = "SALARY RELATED COSTS"
mr = Columns("b").Find(findwhat).Row
'MsgBox mr
Range("a" & mr & ",c" & mr).Borders.LineStyle = xlContinuous
Rows(mr + 1).Insert
End Sub
--
Don Guillett
SalesAid Software
"mike_vr" wrote in message
...
Hi all,
This is slightly long winded but hopefully someone will be able to help me
out here.
I have a text file that once opened needs to be formatted. It consists of
four sections with varying rows in each. I have recorded a macro the easy
way
that does most of what needs to be done, except for one hang-up!!
At the end of each section there is a summary that I would like to have
bordered by two lines and then a blank row inserted underneath, so that
all
the info isn't squashed together. For this I use the "Find" button and
then
type in the description.
The description at the end of each section is always the same (e.g.
"Salary
Related Costs" or "Benefits" etc) and I have used this in the macro as
identifying the line I would like fomatted. However the description has
info
to the left as well as the right. So when I highlight the cells, in the
Macro
it doesn't look at the line that the description is on anymore, but
instead
at a specific set of cells. This would be fine if the text file was the
same
every month, but there are varying numbers of rows.
This is what the code looks like at the moment.
Cells.Find(What:="SALARY RELATED COSTS", After:=ActiveCell, LookIn:= _
xlValues, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext _
, MatchCase:=False).Activate
Selection.End(xlToLeft).Select
Range("A14:K14").Select - THIS IS WHERE THE PROBLEM LIES!!!
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Range("A15").Select
Selection.EntireRow.Insert
So my question at the end of the day, is that is it possible to find a
specific description and only format the cells to the left and right of
that
description, and then add a rown in underneath???
Would appreciate any help, or just to know if this is possible!!!
Thanks in advance
Mike
Reply With Quote
Don Guillett
View Public Profile
Find all posts by Don Guillett