Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 265
Default How to get a cell location

My question is about how to determine a cell location, I mean, if I use:
ActiveSheet.Shapes.AddLine(2, 2, 10, 10)
Then the location starts at 2,2 and ends at 10,10, but if I want that the
line starts at the center of cell A5 and ends at the center of C10 ¿How to
accomplish it???
I need the preceding because I have a sheet with numbers:

A B C D
1 1
2 2 0 1
3 3 1 2
4 4 2 3
5 5 3 0 4
6 6 4 1 5
7 7 5 2 6

And this numbers represent grades of an especial test, each test (columns)
has its own numeric scale (rows) but a graphic should be made to present the
results of the test.
The user grades could be 1,4,1,4 then lines must be drown from 1 to 4 then
from 4 to 1 then from 1 to 4
Hope this have sense
Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default How to get a cell location

Give this a try...

Sub LineStuff()
Dim shp As Shape
Dim rngStartCell As Range
Dim rngEndCell As Range
Dim lngHStart As Long
Dim lngWStart As Long
Dim lngHEnd As Long
Dim lngWEnd As Long

Set rngStartCell = Range("B5")
Set rngEndCell = Range("H10")

With rngStartCell
lngHStart = .Top + .Height / 2
lngWStart = .Left + .Width / 2
End With
With rngEndCell
lngHEnd = .Top + .Height / 2
lngWEnd = .Left + .Width / 2
End With

Set shp = ActiveSheet.Shapes.AddLine(lngWStart, lngHStart, lngWEnd, lngHEnd)

End Sub

--
HTH...

Jim Thomlinson


"filo666" wrote:

My question is about how to determine a cell location, I mean, if I use:
ActiveSheet.Shapes.AddLine(2, 2, 10, 10)
Then the location starts at 2,2 and ends at 10,10, but if I want that the
line starts at the center of cell A5 and ends at the center of C10 ¿How to
accomplish it???
I need the preceding because I have a sheet with numbers:

A B C D
1 1
2 2 0 1
3 3 1 2
4 4 2 3
5 5 3 0 4
6 6 4 1 5
7 7 5 2 6

And this numbers represent grades of an especial test, each test (columns)
has its own numeric scale (rows) but a graphic should be made to present the
results of the test.
The user grades could be 1,4,1,4 then lines must be drown from 1 to 4 then
from 4 to 1 then from 1 to 4
Hope this have sense
Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 265
Default How to get a cell location

thanks Jim

"Jim Thomlinson" wrote:

Give this a try...

Sub LineStuff()
Dim shp As Shape
Dim rngStartCell As Range
Dim rngEndCell As Range
Dim lngHStart As Long
Dim lngWStart As Long
Dim lngHEnd As Long
Dim lngWEnd As Long

Set rngStartCell = Range("B5")
Set rngEndCell = Range("H10")

With rngStartCell
lngHStart = .Top + .Height / 2
lngWStart = .Left + .Width / 2
End With
With rngEndCell
lngHEnd = .Top + .Height / 2
lngWEnd = .Left + .Width / 2
End With

Set shp = ActiveSheet.Shapes.AddLine(lngWStart, lngHStart, lngWEnd, lngHEnd)

End Sub

--
HTH...

Jim Thomlinson


"filo666" wrote:

My question is about how to determine a cell location, I mean, if I use:
ActiveSheet.Shapes.AddLine(2, 2, 10, 10)
Then the location starts at 2,2 and ends at 10,10, but if I want that the
line starts at the center of cell A5 and ends at the center of C10 ¿How to
accomplish it???
I need the preceding because I have a sheet with numbers:

A B C D
1 1
2 2 0 1
3 3 1 2
4 4 2 3
5 5 3 0 4
6 6 4 1 5
7 7 5 2 6

And this numbers represent grades of an especial test, each test (columns)
has its own numeric scale (rows) but a graphic should be made to present the
results of the test.
The user grades could be 1,4,1,4 then lines must be drown from 1 to 4 then
from 4 to 1 then from 1 to 4
Hope this have sense
Thanks

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CELL LOCATION CONGOGRY Excel Worksheet Functions 2 August 5th 09 03:28 PM
Macro - save to current location vs excel default location leezard Excel Discussion (Misc queries) 0 October 28th 08 03:04 PM
automatic offset cell location when there is a value in a selected cell. kuansheng Excel Worksheet Functions 0 February 23rd 06 01:40 AM
Mouse Location, Movement and Spreadsheet Location TCook Excel Programming 3 October 3rd 05 10:23 PM
Populating one cell with the physcial location of a different cell Linking to specific cells in pivot table Excel Programming 2 May 18th 05 11:57 AM


All times are GMT +1. The time now is 03:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"