Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2008

Tip: Looking for answers? Try searching our database.

Macro to call specific values in dimmed araay

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dandeli0n - 14 Feb 2008 09:49 GMT
In my Word 2003 macro project a dimmed array is being build based on a matrix
in an Excel workbook.
The matrix is transfered into the array and the macro uses the values in
each row as variables in the further programming.

I would like to build a new macro that asks for a variable (popup), searches
for this variable in either the array or in the original workbook.
When the specific row is being found then I'd like to use the data as
variables in the rest of the macro

Can anyone help me??
Jean-Guy Marcil - 18 Feb 2008 14:58 GMT
> In my Word 2003 macro project a dimmed array is being build based on a matrix
> in an Excel workbook.
[quoted text clipped - 5 lines]
> When the specific row is being found then I'd like to use the data as
> variables in the rest of the macro

Use the same code you already have to build the array, then search the
array. Here is some simple code to get you going (Of course, I have to build
an array just to show you how to search the array... You would repalce the
array building code I have with your own and modify the searching code
appropriately):

Sub FindArrayValue()

Dim strArray(2, 2, 2) As String
Dim i As Long
Dim j As Long
Dim k As Long
Dim strValue As String
Dim str0 As String
Dim str1 As String
Dim str2 As String

i = 0
j = 0
k = 0
For i = 0 To 2
   For j = 0 To 2
       For k = 0 To 2
           strArray(i, j, k) = i & "_" & j & "_" & k
       Next
   Next
Next

strValue = InputBox("What Variable are you looking for (""x_y_z"" where
numbers must be between 0 and 2)?", "Get value")

i = 0
j = 0
k = 0
For i = 0 To 2
   For j = 0 To 2
       For k = 0 To 2
           If strArray(i, j, k) = strValue Then
               str0 = strArray(i, j, 0)
               str1 = strArray(i, j, 1)
               str2 = strArray(i, j, 2)
               Exit For
           End If
       Next
   Next
Next

MsgBox "The three variables associated with """ & strValue & """ are """ _
   & str0 & """, """ & str1 & """ and """ & str2 & """.", _
   vbInformation, "Results"

End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.