View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Martin[_16_] Martin[_16_] is offline
external usenet poster
 
Posts: 13
Default Help with shortening/cleaning some code please

Roy,

I am no expert. I have been playing with Excel/VBA for some years now and my
limited knowledge has come from searching the newsgroups for similar
scenarios.

If YOU simplify your code, you stand a better chance of understanding it
should you need to amend it in the future.

Three points:

1. Read http://www.cpearson.com/excel/newposte.htm

2. Look at the code yourself...when recording this procedure, you have made
some errors and then rectified them, e.g.,

Selection.NumberFormat = "0.0"
Selection.NumberFormat = "0.00"
and
Selection.Font.Bold = True
Selection.Font.Bold = False

It's unlikely that both lines are required. Start with those.
Look for others.

3. "the row quantities in the "real" file that this
macro has been created for are going to be varying
onevery new incstance of the file...."

Where you have

"Range("C2:L340").Select"

assuming you have no blank cells in Column L,

Range([C2], [L2].End(xlDown)).Select

will work for the last cell down from L2, but
if cells may be blank then you would probably be better
using

Range([C2], [L65536].End(xlUp)).Select

because this goes from L65536 upwards.

Try it. Post back with specific problems and these can be
answered by someone significantly better than me
(and there are lots of those!).

Martin


roy wrote in message
om...
Hi

<snip
CODE ENDS HE::::::::::::::::::::::