Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I plot a circle? 8

Status
Not open for further replies.

gecko3

Electrical
Dec 1, 2005
3
I need to make a smith chart application on excel, I have the equations which give me the circles and curves of the shart but I dont know how to put them into excel... can anyone tell me how I can plot a simple circle using the equation for a circle:

(x-a)^2 + (y-b)^2 = r^2

thank you
 
Replies continue below

Recommended for you

I don't know if this helps you in any way, but although the Excel sheet protection is far from ideal, you can customize a little. You can disable the "locked" property for both cells and objects (such as your chart and circle), to allow it to be modified even though the sheet is protected, and you can protect the sheets for contents (= cells), objects (shapes, charts), and scenarios. Maybe this helps you to set it up the way you want (or close to that).

Cheers,
Joerd

Please see FAQ731-376 for tips on how to make the best use of Eng-Tips.
 
Denial-
I guess you can protect a worksheet from the user but allow it to be modified by macros. I just found this on John Walkenbach's spreadsheet page.


Can I set things up so my VBA macro can make changes to Locked cells on a protected sheet?
Yes, you can write a macro that protects the worksheet, but still allows changes via macro code. The trick is to protect the sheet with the UserInterfaceOnly parameter. Here's an example:

ActiveSheet.Protect UserInterfaceOnly:=True
After this statement is executed, the worksheet is protected -- but your VBA code will still be able to make changes to locked cells and perform other operation that are not possible on a protected worksheet.
 
Panars,

You had me worried there for a moment: I thought I was going to end up owing you two beers rather than just the one. Luckily this turned out not to be the case, and I was rescued by a subtle Microsoft gotcha.

My objective is to avoid having to embed the password in the VBA code. However the state UserInterfaceOnly:=True does not persist when the worksheet is closed and then reopened. The way around this, of course, is to reset the worksheet to UserInterfaceOnly:=True when the workbook is opened.

And guess what? Setting UserInterfaceOnly:=True on a locked sheet requires a password (on Excel 2002 at least). So all I achieved was moving the embedded password from one bit of code to another.

But thanks for the suggestion. I knew nothing about UserInterfaceOnly, and the knowledge I have gained will be useful somewhere.

In due course I'll investigate Joerd's suggestions (for which, my thanks).
 
I found an easy way to keep X and Y scales equal without using VBA.

step 1. Make chart area square.

step 2.

Add an extra graph to the chart. It will have only two points from lower left corner to upper right corner.
Condition Y2-Y1 = X2-X1 will assure equal X and Y scales.

calculate follwing values

dX = Xmax - Xmin
dY = Ymax - Ymin
extraX = max(dY-dX,0)
extraY = max(dX-dY,0)

where Xmax, Xmin, Ymax and Ymin are maximum and minimum values of all graphs in the chart.

coordinates of diagonal line
X1 = Xmin - extraX/2 : Y1 = Ymin - extraY/2
X2 = Xmax + extraX/2 : Y2 = Ymax + extraY/2

to make this line invisible in Format Data Series set Line and Marker to none.









 
That's a good way to do it without vba. Also has the advantage that you don't have to run the vba macro for scaling. I'm happy with the vba solution - no clutter on the spreadsheet itself and can plug it into another spreadsheet with a single cut/paste.

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor