drawing shapes using coordinates

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Drawing shapes using coordinates contained in cells

Drawing shapes using coordinates contained in cells

resolvedResolved · High Priority · Version 2007

Frederic has attended:
Access Introduction course
Access Intermediate course
Excel VBA Intro Intermediate course

Drawing shapes using coordinates contained in cells

Hello,

I would like to insert circles on sheet (2) of my workbook using the coordinates stored in two columns on sheet (1).
These coordinates are stored as Letters (that will give me the column where to insert the shape) and Numbers (that will give me the row where to insert the shape).
Below is my code so far, but when I run it, it doesn't do much to my second worksheet, actually nothing.
Could you point out where is my mistake please?

Thank you in advance for your help.

Fred.

Sub PopulateKinomeTree()

Dim strCells As String
Dim LocationColumn As String
Dim LocationRow As String
Dim currentRow As Integer
Dim NumberOfRows As Integer
Dim myDocument As Worksheet


Application.ScreenUpdating = False


NumberOfRows = Worksheets(1).Range("D5").CurrentRegion.Rows.Count

MsgBox (NumberOfRows)


For currentRow = 2 To NumberOfRows

On Error Resume Next


LocationColumn = Worksheets(1).Range("D" & currentRow).Text
LocationRow = Worksheets(1).Range("E" & currentRow).Text


strCells = LocationColumn & LocationRow


Set myDocument = Worksheets(2)


myDocument.Shapes.AddShape msoShapeOval, Range("strCells").Left, _
Range("strcells").Top, 8, 8

Next currentRow

Application.ScreenUpdating = True


End Sub

RE: drawing shapes using coordinates contained in cells

Hi Frederic


Thank you for your question & apologies for the delay in getting back to you.

The Excel VBA trainer will respond to your question as soon as possible.

Thank you for your patience.

Regards,


Nafeesa

Microsoft Office Specialist Trainer

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Generating Random Numbers

To generate a random number in Excel use the = RAND() function.

The value returned will always be between 0 and 1. To convert this to some other random value, you will need to multiply the result by the highest number you want to consider. For example, if you wanted a random number between 1 and 25, you could use the following code line:
= INT(25 * RAND()+ 1)

Since RAND() will always returns a value between 0 and 1 (but never 1 itself), multiplying what it returns by 25 and then using the Integer function INT on that result will return a whole number between 0 and 24.

Finally, 1 is added to this result, so that x will be equal to a number between 1 and 25, inclusive

View all Excel hints and tips


Server loaded in 0.07 secs.