Thread: Bad code?
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Spiky Spiky is offline
external usenet poster
 
Posts: 622
Default Bad code?

Ok, I am going crazy. Below is a macro I recorded and stored in
Personal.xls, in its entirety. It fixes the garbage that comes in from
an html data source that I must use frequently (online enterprise
software). It seems to cause problems, and I don't know why, it
appears fine and simple. Is there anything wrong with this? Or is this
just SOP for Excel and other people have the same problems? I would
appreciate any insight. (WinXP, Excel 2003, Dell Optiplex)

This is my workflow:
I copy/paste data, run the macro, copy the data to a preformated area
in the same workbook to look pretty, then delete the raw data.

I have a coworker with the same job. She does the same workflow,
except doing it slowly without a macro. None of these problems surface
for her.

Here are the problems I have after running this macro:

1) Redo/Repeat stops working. It says "Repeat Macros" in the Edit
menu, but doesn't actually DO anything when selected. It never changes
from "Repeat Macros", so the Repeat command is lost til I restart
Excel. Menu selection, F4, CTRL-Y, nothing works.
2) It affects the size of the file. I always delete the entire columns
where the download was pasted, yet the workbook keeps growing as if I
leave the full raw data in there every single time I do this. After a
few months, the file has quadrupled in size.
3) It 'sticks' to the file somehow. When I send files to certain
companies, their over-zealous security deletes any emails with
attachments containing macros. These files do not contain this (or
any) macro, it is stored in Personal. Yet the firewalls claim there is
a macro after I run it on these files, and block my emails.


Code:

Sub Clean()
'
' Clean Macro
' Macro recorded 1/25/2007
'

'
Cells.Replace What:=" ", Replacement:="", LookAt:=xlPart,
SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False,
ReplaceFormat:=False
ActiveSheet.DrawingObjects.Delete
Cells.Select
Selection.UnMerge
Selection.WrapText = False
Range("B:IV").Select
Selection.Style = "Comma"
Range("A1").Select

End Sub