Link to home
Start Free TrialLog in
Avatar of Catt999
Catt999Flag for Canada

asked on

Excel - macro/code to delete and change line style of drawing objects

Hi experts,

I was hoping someone could tell me how I can automatically delete some drawing objects (lines) and then change the line style of others.

Here is the scenerio.....I have approximately 100 spreadsheets, each has 12 columns.  These spreadsheets are generated from Oracle ADI...they are financial statements.  The "double line" that is in the spreadsheet is not printing very well as it is too squished together.  I have tried several different printers to try to remedy this but the results are the same.  I have - found that all the lines in these sheets are single line drawing objects, some just close together to make it look like a double line.  

I would like a little routine that would do the following:

- Delete lines 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96
- Then change the format of the following lines from 3/4 point single to 3 point double  73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95

Hopefully someone can help me with this.  Anything would be really appreciated!!!

Thanks in advance,
Connie
Avatar of yairsuari
yairsuari

put that in a macro seems like its going to help you


For i = 1 To 12

a = i * 2 + 72
   
    ActiveSheet.Shapes("Line" & a).Select
    Selection.Delete
Next i

For i = 1 To 12
a = i + 3
    ActiveSheet.Shapes("Line" & a).Select
    Selection.ShapeRange.Line.Style = ********
Next a

if i understand correctly that is what you want for the lines that are left on the screen

For i = 1 To 12

a = i * 2 + 72
   
   ActiveSheet.Shapes("Line" & a).Select
   Selection.Delete
Next i

For i = 1 To 12
a = i + 3
   ActiveSheet.Shapes("Line" & a).Select
   Selection.ShapeRange.Line.Weight = 2#

Next a

Avatar of Catt999

ASKER

vairsuari,

Thanks so much.  I think you have a grasp on what I want to do.  I have tried your suggestion but am having problems with the second Next statement.

When I run the macro I get a message "Invalid next control variable reference" and it is showing as not liking the "a" in "next a".  I tried changing this to "next i" but then received error "system error &H80070057 (-2147024809)"  I clicked on Help but it gave me nothing.  Ideas?

Connie
For i = 1 To 12

a = i * 2 + 72

   ActiveSheet.Shapes("Line " & a).Select
  Selection.Delete
Next i

For i = 1 To 12
a = i + 3
    ActiveSheet.Shapes("Line " & a).Select
    Selection.ShapeRange.Line.Weight = 2#


Next i

and now?

if you saved the sheet after runing my first one i may have got you in trouble so please try it and save your sheet only if it works
ASKER CERTIFIED SOLUTION
Avatar of yairsuari
yairsuari

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Catt999

ASKER

yairsuari,

Thanks so much!!  I have it working but I cannot figure out how to change the line from single to double.  I have been looking in help but have not found anything yet.  Suggestions??

Connie
Avatar of Catt999

ASKER

Hi,

I have managed to get the double lines to work by recording a macro while selecting and changing the style and then using that code.

Thanks for all your help!!!

Connie