PDA

View Full Version : Excel Module to find() and assign variables



Antonlnd
06-02-2014, 07:02 AM
Hello, I wanted to build a module that can help assign data to a 4D array. the data sheet would have a column A like this: Apples Big Apples Small Apples Medium Bagels Small Bagels Medium Bagels big and column B would have unique numerical ID's for each of the objects. I need the module to group all the Apple objects together, and assign the names to a variable such as apples(1,0,0,0) = apples, apples(1,1,0,0) = 993993 I am having a few problems with the code and have not been able to get it right... here is what I have been messing around with to learn the find() and split() functions. Best, A Sub workbk1() Dim aa(1 To 88, 1 To 88) As String Dim i As Integer For b = 1 To 5 For i = 2 To 5 firstname = Split(Cells(i, 1), " ")(0) Set aaZ = Cells(i, 1).Find(firstname, LookIn:=xlValues, lookat:=xlPart) If Not aaZ Is Nothing Then c = c + 1 a = a + 1 aa(a, a) = Cells(i, 1).Value aa(a, c) = Cells(i, 2).Value End If Next i Next b

patel
06-02-2014, 07:12 AM
attach please a sample file with data, code, desired result

Antonlnd
06-02-2014, 07:42 AM
added attachment, Thank you.

Paul_Hossler
06-02-2014, 08:36 AM
I think an XLSM with the Before sheet and the After sheet example would be more helpful to understand what you're looking to do