• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Macro that would draw a line using cell borders

Tom T Hall

New Member
I have been trying to make a small drawing application in Excel 2010 using macros. To be more specific, I would like the user to be able to enter a line dimension, select a starting point within a predefined area, click on a direction arrow (a shape, showing north, south, east, or west) and draw a line (using a cell border) in the specified direction. After the line is drawn, a text box with the user entered dimension will be placed within the predefined drawing area. I have had limited success using predefined lengths and directions, but it is very cumbersome. Is there a way to make the user inputted length a variable "X" that will draw the cell outline "X" number of boxes north, south, east or west? Could you then replace the text in the dimension text box with that same variable? I have attached a pick of what the spreadsheet would look like. Any help would be appreciated.EXCELHELPPIC1.JPG
 
Tom

Firstly, Welcome to the Chandoo.org Forums

Have a look at the attached

It assumes that you are drawing using the upper left corner of the cell as a pointer (Stylus)

The color/line thickness of the Distance Cell (between the arrows shows what line color / thickness it will be)

I've added a Clear All, and Change Color and Line Thickness functions
The code also checks that you are on the Canvas area before you start.

Have now added Diagonal lines!
 

Attachments

  • Excel_Draw.xlsm
    42.9 KB · Views: 22
Last edited:
Thank you so much. I knew this could be done but just could not wrap my head around the coding. I love the diagonal lines. I didn't even know that Excel would let you draw diagonals. How hard would it be to add an undo button to undo the last line drawn in case you make a mistake?
 
Back
Top