LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 42
Default Formatting via a macro

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
 
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
Dual Formatting in Macro Slashman Excel Worksheet Functions 9 September 5th 06 01:06 AM
Conditional Formatting in a Macro Ed Excel Discussion (Misc queries) 2 August 28th 06 11:23 PM
Compiling macro based on cell values simonsmith Excel Discussion (Misc queries) 1 May 16th 06 08:31 PM
Macro not formatting correctly js8373 Excel Discussion (Misc queries) 0 February 28th 06 07:53 PM
Search, Copy, Paste Macro in Excel [email protected] Excel Worksheet Functions 0 January 3rd 06 06:51 PM


All times are GMT +1. The time now is 04:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"