Draw Cube using excel

J

jonathan9560

Is there any way to use excel to draw cube based on length, width and
height. I tried using a scatter graph but was only able to adjust width
and height and could not figure out how to change length. I feel I have
reached the limits of my math ability. I am trying to visualize the
way certain boxes are shaped. Any help would be greatly appreciated.
Thanks in advance
 
G

Gord Dibben

If just for viewing and not as a math exercise use the drawing toolbar.

Draw a cube from autoshapes or draw a rectangle and give it 3-d style with no
color.


Gord Dibben MS Excel MVP
 
J

jonathan9560

Gord said:
If just for viewing and not as a math exercise use the drawing toolbar.

Draw a cube from autoshapes or draw a rectangle and give it 3-d style with no
color.


Gord Dibben MS Excel MVP


I would like for the Cube to be dynamic as I input new L*W*H dimensions
 
B

Bill Sharpe

I would like for the Cube to be dynamic as I input new L*W*H dimensions
Excel probably isn't the best tool for this. I suggest a Google search
for "3d drawing program."

Bill
 
G

Guest

This code will draw a "cube" parametrically to values stated in A1:A4

The depth dimension is not controllable directly, except that it varies
according to the shorter of the Width and Height dimensions.


Sub DrawCube()
'=============================================
'draws a cube to cell values, by Chuck Roberts, CABGx3
'A1=Horizontal position
'A2=Vertical position
'A3=Width
'A4=Height
'==============================================
Dim shp As Shape
For Each shp In ActiveWorkbook.ActiveSheet.Shapes
If shp.AutoShapeType = msoShapeCube Then shp.Delete
Next shp
ActiveSheet.Shapes.AddShape(msoShapeCube, Range("a1").Value,
Range("a2").Value, Range("a3").Value, Range("a4").Value).Select
Range("A5").Select
End Sub

hth
Vaya con Dios,
Chuck, CABGx3
 
J

jonathan9560

CLR said:
This code will draw a "cube" parametrically to values stated in A1:A4

The depth dimension is not controllable directly, except that it varies
according to the shorter of the Width and Height dimensions.


Sub DrawCube()
'=============================================
'draws a cube to cell values, by Chuck Roberts, CABGx3
'A1=Horizontal position
'A2=Vertical position
'A3=Width
'A4=Height
'==============================================
Dim shp As Shape
For Each shp In ActiveWorkbook.ActiveSheet.Shapes
If shp.AutoShapeType = msoShapeCube Then shp.Delete
Next shp
ActiveSheet.Shapes.AddShape(msoShapeCube, Range("a1").Value,
Range("a2").Value, Range("a3").Value, Range("a4").Value).Select
Range("A5").Select
End Sub

hth
Vaya con Dios,
Chuck, CABGx3


I modified your code, hope you don't mind, it seems to give me what I
am looking for. Thanks for the great idea.

Sub DrawCube()
'=============================================
'draws a cube to cell values, by Chuck Roberts, CABGx3
'A1=Horizontal position
'A2=Vertical position
'A3=Width
'A4=Height
A5=Length <---- added
'==============================================
Dim shp As Shape

ActiveSheet.Shapes.AddShape(msoShapeRectangle, Range("a1").Value,
Range("a2").Value, Range("a3").Value, Range("a4").Value).Select
Shapes.SelectAll

Selection.ShapeRange.ThreeD.Visible = msoTrue
Selection.ShapeRange.ThreeD.Depth = Range("a5")
Range("e4").Select



End Sub
 
C

CLR

Of course I don't mind, I'm glad you've got something you can use.........

in fact I learned something too.......so, my thanks back to you.


Vaya con Dios,
Chuck, CABGx3
 
G

Guest

For those dummies like myself who aren't very Visual Basic astute, could you
please explain how to use this code. I copied the code into the Sheet 1 VBA
window and enter values in cells A1 thru A5, and nothing happens. I'm
confused!!

Thanks in advance for your patience.
 
J

jonathan9560

Traveller said:
For those dummies like myself who aren't very Visual Basic astute, could you
please explain how to use this code. I copied the code into the Sheet 1 VBA
window and enter values in cells A1 thru A5, and nothing happens. I'm
confused!!

Thanks in advance for your patience.

For example
A1 100
A2 100
A3 50 <-- Width
A4 50 <-- Height
A4 50 <-- Length

Also make sure when pasting the code that none of the text is red. If
so click to the left hand side of the second line of red text and push
backspace. This will fix the code (i had the hardest time until I
figured that out, I am new myself to VBA).
 
J

jonathan9560

Traveller said:
For those dummies like myself who aren't very Visual Basic astute, could you
please explain how to use this code. I copied the code into the Sheet 1 VBA
window and enter values in cells A1 thru A5, and nothing happens. I'm
confused!!

Thanks in advance for your patience.

One other thing you must also select run macro from the tool menu
(macro name is: DrawCube)
 
Joined
Mar 11, 2010
Messages
1
Reaction score
0
You mentioned "The depth dimension is not controllable directly". I've put this exact code fragment into Excel and PowerPoint and in both cases, the .threed.depth=50 statement (or any other value) does nothing. If the shape is normally a 2D, such as an msoShapeRectange, the depth field works fine. So, given this, does anyone know how to actually change the depth on a msoShapeCube from Excel VBA?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top