Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Variant Trees/Lisp Like Lists in a single cell.

I want to be able to create Lisp like nested lists in a spreadsheet. This
would have a wide variety of applications. For instance I could store and ND
array in a single cell of the spreadsheet. I am however not able to Nest more
then 2 deep without getting error 2015.

Right now I am working on a simple function to display the list. Here is an
example function call:

ListDsp(1,List(List(7,List(8,9)),4))

This should return:
€˜[1[7,[8,9]],4]

The display function is used to represent it in the spreadsheet. My idea is
if I passed this to an addList the add List would have input arguments of
type range. Therefore it would have access to the underlying formula in the
cell and be able to replace ListDsp with lisp and then let Excel evaluate the
new expression. Here is my code:

Public Function ListDsp(ParamArray args() As Variant) As String

ListDsp = "["

For i = LBound(args, 1) To UBound(args, 1) - 1
If IsArray(args(i)) Then
ListDsp = ListDsp & ListDspStrip(args(i)) & ","

Else
ListDsp = ListDsp & args(i) & ","
End If
Next i
If IsArray(args(i)) Then
ListDsp = ListDsp & ListDspStrip(args(UBound(args))) & "]"
Else
ListDsp = ListDsp & args(UBound(args)) & "]"
End If
End Function
Public Function ListDspStrip(ParamArray args0() As Variant) As String
' Split (myStr,delim)
' re.Pattern = "^\[{0,1}(.*)\]${0,1}" 'Trim Brackets
'Dim result As Range(
'result.value = args(0)
args = args0(0)

ListDspStrip = "["
For i = LBound(args, 1) To UBound(args, 1) - 1
If IsArray(args(i)) Then
ListDspStrip = ListDspStrip & ListDspStrip(args(i)) & ","

Else
ListDspStrip = ListDspStrip & args(i) & ","
End If
Next i
If IsArray(args(i)) Then
ListDspStrip = ListDspStrip & ListDspStrip(args(UBound(args))) & "]"
Else
ListDspStrip = ListDspStrip & args(UBound(args)) & "]"
End If
End Function
Public Function List(ParamArray args() As Variant) As Variant
List = args
End Function

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
Values from 3 separate drop-down lists entered into single cell Smatass Excel Worksheet Functions 4 September 16th 07 10:17 AM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 6 November 9th 05 05:54 AM
Array problem: Key words-Variant Array, single-element, type mismatch error davidm Excel Programming 1 November 8th 05 04:21 AM
telephone trees rbj Charts and Charting in Excel 0 August 4th 05 08:58 PM
how to add two data validation lists to a single cell? Mike Peter Excel Worksheet Functions 1 December 8th 04 08:22 PM


All times are GMT +1. The time now is 11:47 PM.

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"