I am very new to Excel VBA Code so please forgive my coding clumsiness. I have the following Code that I use to format various reports. I want to be able to install it automatically for CSV files I open, format then save as xls files. I have tried creating both an xla add-in file and when that didn't work, an XLSTART auto file, both with the below code inserted and saved.
The problem I have is that the add-in file does not show the marcos, or if using the XLSTART file they both fail on the Range("A2").Select statement but if I disable both and manually copy and paste the code into the 'vIEW CODE sheet option of an opened CSV file it works fine. I can view the code when using the add-in but it still fails to execute on any range select statement. The add-in is available to select via the add-ins menu, but after doing so the macros still fail to be available via ALT-F8 and fail when run through the VBA Editor. Paste it in manallu however and it runs fine. Any ideas what I am doing wrong ? Many thanks for any assistance. ======================= Sub AutoFit() Dim Del_Char As Integer Range("A2").Select ActiveWindow.FreezePanes = True Rows("1:1").Select Cells.EntireColumn.AutoFit With Selection.Interior .ColorIndex = 16 .Pattern = xlSolid End With Selection.Font.ColorIndex = 2 Selection.HorizontalAlignment = xlLeft Range("A2").Select Del_Char = Len(Selection.End(xlDown).Select) If Del_Char = 4 Then Selection.ClearContents End If Range("A2").Select End Sub Sub Color_OffSet() Dim str_Date As Date Selection.CurrentRegion.Select iRows = Selection.Rows.Count iColumns = Selection.Columns.Count For iC = 2 To 2 For iR = 2 To iRows Select Case Selection.Item(iR, iC).Value Case "YELLOW" Selection.EntireRow(iR).Interior.ColorIndex = 6 Case "ORANGE" Selection.EntireRow(iR).Interior.ColorIndex = 45 Case "BLUE" Selection.EntireRow(iR).Interior.ColorIndex = 33 End Select Next iR Next iC Range("A2").Select End Sub Sub AlignShrinkToFit() Selection.CurrentRegion.Select Selection.HorizontalAlignment = xlLeft Columns("A:AP").Select Selection.HorizontalAlignment = xlRight Columns("L").Select Selection.HorizontalAlignment = xlLeft Selection.CurrentRegion.Select iRows = Selection.Rows.Count iCols = Selection.Columns.Count Columns("AR:BE").Select Selection.EntireRow.ShrinkToFit = True Range("A2").Select End Sub =============== -- FORUM RULES (934+ members already BANNED for violation) 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Cross-promotion of, or links to, forums competitive to this forum in signatures are prohibited. NOTE : Don't ever post personal or confidential data in a workbook. Forum owners and members are not responsible for any loss. ------------------------------------------------------------------------------------------------------ To post to this group, send email to excel-macros@googlegroups.com