LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default Programming a NAME

I need to place several "blocks", each block consisting of several cells with
values and references to other values (in other blocks).
The number of these blocks of cells is not fixed - it will change at run
time based on user input.
So for each block, I need to be able to refer to the values elsewhere on the
sheet.

I am using a Type called "converter", which has several members, those being
the cell location where the block is placed (the block contains 9 cells, the
reference location is one of these cells, and the other values are placed
relative to that cell).

My Type definition looks like this (this is truncated);

Public Type Converter_Type
Efficiency(50) As Double
Pdiss(50) As Double
Vin(50) As Double
Col(50) As Integer 'the reference column number
Row(50) As Integer 'the reference row number
End Type

Public Converter = Converter_Type


So then, as the user adds one of these blocks, 9 cells are filled. Some are
text, most are values. Some of these are used by other blocks used elsewhere.
So I need to refer to each cell by name, so that I can build meaningful
expressions for the other calculations. This is where I am stumped.

The excel equivalent of what I want to do is to define a Name for each
cell's contents. Here is what I have now (one of the many versions that I
have tried):

ActiveWorkbook.Names.Add name:="ConvVout" & LTrim(Str(n)), _
RefersToR1C1:="Sheet1!" & (convert_asc(Converter.Col(n) + 1)) _
& LTrim(Str(Converter.Row(n)))

What I am trying to do in this statement is assign the name ConvVout1 to the
value in the cell just to the right of the "reference cell". The reference
cell is located at the row and column saved with the Type variable in the Row
and Col elements. That is, the reference cell is at Converter.Row(n) and
Converter.Col(n).

Executing this code results in a name definition that reads correctly in the
worksheet (reading it at the Edit/Define page). That is, it says that cell
G15 has the name =ConvVout1 for example.

But if I edit a cell (manually) and place "=ConvVout1", what I get in that
cell is the name of the cell where the value of ConvVout1 exists. So for
example, I get Sheet1!G15 in that cell. Not the number that's in G15, which
is what I want.

I hope all that makes sense. If you have made it this far, thanks.
I have been working on this for hours and can't make it work right. I have
been trying to figure out the difference between the various versions of
"refersto". Documentation is very unclear.

Thanks in advance!
dan
 
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
programming help Stan Excel Discussion (Misc queries) 2 April 23rd 07 02:44 PM
programming Daren Excel Programming 1 November 10th 05 09:55 PM
programming VBA Mark Excel Programming 1 January 18th 05 09:11 AM
Programming in VB Kamyk Excel Programming 2 July 8th 04 11:02 PM
vba programming sal Excel Programming 1 October 27th 03 07:44 PM


All times are GMT +1. The time now is 02:43 AM.

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

About Us

"It's about Microsoft Excel"