Consulting

Results 1 to 4 of 4

Thread: Excel Module to find() and assign variables

  1. #1
    VBAX Newbie
    Joined
    Jun 2014
    Posts
    3
    Location

    Excel Module to find() and assign variables

    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
    Attached Files Attached Files
    Last edited by Antonlnd; 06-02-2014 at 07:41 AM.

  2. #2
    VBAX Mentor
    Joined
    Jul 2012
    Posts
    398
    Location
    attach please a sample file with data, code, desired result

  3. #3
    VBAX Newbie
    Joined
    Jun 2014
    Posts
    3
    Location
    added attachment, Thank you.

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    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
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •