PDA

View Full Version : Coordinates for my shape and placing the cursor



ANDY
08-29-2007, 11:30 PM
Hi,

In the attached file there is some (not so well written) VB code that when I change any of the values in the yellow shaded areas on the spreadsheet makes changes to rectangle 1. The problem is that after the code runs the focus automatically goes to rectangle 1...I need the cursor to go to the cell to the right of the cell which was last updated.

Second issue is this...

In the drawing menu I set Draw/Snap to grid so I can quickly and accurately move the rectangle (there will be more to be added later) into another cell; let's say from A1 to A2. But when I close the spreadsheet then re-open it the snap to grid has stopped. Is there code to start the snap to grid when I open the spreadsheet?

Last problem (for now)...

If I move the rectangle from A1 to A2 is there any way to identify where the rectangle is located? The idea is to give A1 and A2 etc values then based on the number inside the rectangle make a calculation. e.g.

Rectangle value = 64
A1 = 2 therefore if the rectangle sits here the sum = 128
A2 = 4 therefore if the rectangle sits here the sum = 256

Thanks to all for any help.

Cheers Andy

Bob Phillips
08-29-2007, 11:41 PM
Q1 where is the code

Q3 MsgBox ActiveSheet.Shapes("Rectangle 1").TopLeftCell.Address

ANDY
08-29-2007, 11:45 PM
Hi There,

Thanks for replying...

Q1 code is in VB sheet1 (sheet1)

Thanks Andy

Bob Phillips
08-30-2007, 12:12 AM
Add



Target.Offset(0,1).Select


at the end of the evnt

ANDY
08-30-2007, 12:21 AM
Your resolve for Q1 works perfectly. Many thanks.

Re your answer to Q3 (MsgBox ActiveSheet.Shapes("Rectangle 1").TopLeftCell.Address) would you be kind enough to elaborate as to how to actually enter this into my example? Perhaps you could update the example file and re-post it?

Thanks again for all the help, it really is appreciated.

Ciao Andy

Bob Phillips
08-30-2007, 02:02 AM
Not really Andy, as I am not sure where your code for moving the recatngls is.

You said that if you move the rectangle from A1 to A2, is there any way to identify where the rectangle is located? The code I gave shows you the cell address of the top left cell that the shape is over. Remove the .Address bit, and you have a cell object itself.

You should be able to use that within your code.

ANDY
08-30-2007, 02:32 AM
Hi Nihil,

I was actually going to drag and drop the rectangles into various positions on the spreadsheet then I need the result of the value shown in the rectangle multiplied by the value in (let's say) cell A1 to appear in (let's say) A3. So...each time I move any rectangle into another cell the value in A3 changes. Do you have any idea how I can do this?

Ciao Andy

Bob Phillips
08-30-2007, 02:47 AM
I think you will be out of luck. I know of no events that are triggered by a shape.

ANDY
08-30-2007, 03:11 AM
Thanks again Nihil

Ciao Andy

unmarkedhelicopter
08-30-2007, 06:04 AM
Who the hell is Nihil ??? :dunno

ANDY
08-30-2007, 06:09 AM
Whoops!

Not paying attention...just read the last line of the message from "xld" and thought it was his name. Now my eyes are open I can see it is a quote of some sort...

What a plocker I am!

HeHeHe...

Ciao and sorry - Andy

Bob Phillips
08-30-2007, 06:12 AM
You know ...

FloccinauciNIHILipilification

... just about sums me up.

unmarkedhelicopter
08-30-2007, 06:12 AM
Nihil simul inventum est et perfectum
Nothing Simultaneous Invented Is And Perfected
Nothing is ever simultaneously invented and perfected