PDA

View Full Version : [SOLVED] Placing an arrow and change its position



rdavid87
12-02-2013, 07:29 AM
Hi, My problem is that I place an arrow (Straight Arrow Connector) between two countries on a map. For example between Germany and France and I have a specific number which represents the export - import. Now if this number is negative then the arrow must point towards Germany (import) if it is positive then towards France (export). How would you code this in VBA? I tried with rotate: if it is for example negative it rotates 180 degrees but it doesn't seem to be correct because if I add as an input a negative number twice then it makes a second turn which shows an incorrect direction.
Thanks for your help in advance!

patel
12-02-2013, 07:56 AM
can you attach a sample file with notes ?

Bob Phillips
12-02-2013, 08:13 AM
Couldn't you have two arrows, one going each way, and then depending upon the value hide one or the other?

Aflatoon
12-02-2013, 09:01 AM
Perhaps something like this:

With shpArrow.Line
If somevalue > 0 Then
.EndArrowheadStyle = msoArrowheadTriangle
.BeginArrowheadStyle = msoArrowheadNone
Else
.BeginArrowheadStyle = msoArrowheadTriangle
.EndArrowheadStyle = msoArrowheadNone
End If
End With

rdavid87
12-02-2013, 11:40 PM
What I have now is this:



Sheets(1).TextBox6.Value = Round(Abs(Sheet2.Range("I3").Value), 0) 'FR-DE' 'The value that goes into a text box
If (Sheet2.Range("I3").Value < 0) Then Sheets(1).Shapes("Straight Arrow Connector 10").IncrementRotation 180# 'If the value is negative it rotates 180
If (Sheet2.Range("I3").Value <> 0) Then Sheets(1).Shapes("Straight Arrow Connector 10").Visible = msoTrue 'Just to make it invisible if it has no value


10916

rdavid87
12-02-2013, 11:43 PM
With shpArrow.Line If somevalue > 0 Then
.EndArrowheadStyle = msoArrowheadTriangle
.BeginArrowheadStyle = msoArrowheadNone
Else
.BeginArrowheadStyle = msoArrowheadTriangle
.EndArrowheadStyle = msoArrowheadNone
End If End With

This solution looks promising but how do I use it? Could you show me an example?

Aflatoon
12-03-2013, 12:02 AM
That is an example. shpArrow is a reference to your shape and somevalue is the value you are checking.

rdavid87
12-03-2013, 12:21 AM
That is an example. shpArrow is a reference to your shape and somevalue is the value you are checking.
Ohh now I understand how it works! Many thanks for your help!

Bob Phillips
12-03-2013, 03:17 AM
I like that graphic, I find it quite effective. I guess it does suffer a bit from too much void, France would have 5 or 6 arrows over its border, but in comparison to the size that is not much, there would be lots of white arid space, which is not good on a graphic. The big problem though as in all such graphics is the map, building a map is too difficult by degrees.

rdavid87
12-03-2013, 03:26 AM
I like that graphic, I find it quite effective. I guess it does suffer a bit from too much void, France would have 5 or 6 arrows over its border, but in comparison to the size that is not much, there would be lots of white arid space, which is not good on a graphic. The big problem though as in all such graphics is the map, building a map is too difficult by degrees.

Well it's true but for example Eastern-Europe is very crowded with lots of small countries with many many borders. That part of the map is very crowded with arrows.

Bob Phillips
12-03-2013, 03:33 AM
I understand the problem. Perhaps the answer is to do a map schematic where the countries are not to scale. UK would be a triangle, and so on, although that requires a lot of creativity in creating such a schematic (the London Underground is not considered a classic because it is easy and obvious :)). You probably also need some form of labelling, I know (think I know?) that the small country sandwiched between Belgium, France is Germany is Luxembourg, but not everyone necessarily would. And when it comes to those Eastern European countries, sometimes it is a bit hit and miss as to whether I know which is which.

Just musing out aloud, as I said, the overall effect is good IMO.