+ Reply to Thread
Results 1 to 9 of 9

Cells Iteration

Hybrid View

Mut Cells Iteration 05-02-2010, 08:33 PM
jeffreybrown Re: Cells Iteration 05-02-2010, 08:44 PM
Mut Re: Cells Iteration 05-02-2010, 09:38 PM
JBeaucaire Re: Cells Iteration 05-02-2010, 10:13 PM
JBeaucaire Re: Cells Iteration 05-02-2010, 11:18 PM
jeffreybrown Re: Cells Iteration 05-02-2010, 11:24 PM
JBeaucaire Re: Cells Iteration 05-03-2010, 02:45 AM
Mut Re: Cells Iteration 05-03-2010, 07:54 PM
JBeaucaire Re: Cells Iteration 05-03-2010, 08:11 PM
  1. #1
    Registered User
    Join Date
    01-19-2006
    Posts
    28

    Cells Iteration

    Dear all,

    I have DATA 1 and DATA 2
    And, I have to iterate every DATA 1 to every DATA 2
    For example:
    DATA 1 | DATA 2
    J | J
    F | J
    S | F

    RESULT
    J | J
    J | J
    J | F
    F | J
    F | J
    F | F
    S | J
    S | J
    S | F

    I attached the file for clear example
    Could it be automatically by macros?
    Any help would be appreciated

    Thanks,
    Mut
    Attached Files Attached Files

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Cells Iteration

    Courtesy of martindwilson...I saw him do this today...

    In I1 =INDEX($A$2:$A$12,MATCH(J2&K2,INDEX($B$2:$B$12&$C$2:$C$12,0),0))
    In L1 =INDEX($E$2:$E$12,MATCH(M2&N2,INDEX($F$2:$F$12&$G$2:$G$12,0),0))

  3. #3
    Registered User
    Join Date
    01-19-2006
    Posts
    28

    Re: Cells Iteration

    But the formula need values in coloumn J&K or M&N. How MATCH will work if we don't know those values of iteration before.
    What I need is the iteration from range A2:C12 with E2:G7..

    Thanks,
    MT

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Cells Iteration

    The VBA approach to this problem:
    Option Explicit
    
    Sub IterateDataSets()
    'Jerry Beaucaire   5/2/2010
    'Duplicate a 2nd range of data once for each
    'row of data in 1st range of data
    Dim LR As Long, Rw As Long, NR As Long
    Dim CpyRNG As Range
    Application.ScreenUpdating = False
    
    Range("I:N").Clear
    LR = Range("A" & Rows.Count).End(xlUp).Row
    Set CpyRNG = Range("E2", Range("E2").End(xlDown).End(xlToRight))
    
        For Rw = 2 To LR
            NR = Range("L" & Rows.Count).End(xlUp).Row + 1
            CpyRNG.Copy Range("L" & NR)
            Range("A" & Rw).Resize(, 3).Copy Range("I" & NR).Resize(CpyRNG.Rows.Count)
        Next Rw
    
    Set CpyRNG = Nothing
    Range("I1") = "RESULT"
    Range("I1").Font.Bold = True
    Application.ScreenUpdating = True
    End Sub
    (sheet attached)
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Cells Iteration

    Quote Originally Posted by jeffreybrown (via Private Message)
    I see where you Set CpyRNG and would like to know how I can see the entire range as it is held in memory.

    As I step through the code using F8 I know I can open up the Locals window and view the values of the variable plus many other things, but how can I see the CpyRNG?
    Jeffrey, please continue the thread discussion in the open forum, as per the Forum Rules. (See rule #4) Thanks.

    To simply see the address is easy:
    Debug.Print CpyRNG.Address
    ...will print the range in the Immediate Window (CTRL-G to see it if it's not open already).


    You need to see individual values within the CpyRNG? Any particular reason why? That starts to get a bit ugly to read code-wise, and I don't do that very often. If the values inside the CpyRNG are relevant to the copy procedure in some way, I would probably rethink the whole thing, so more info makes it easier to understand what you're thinking.

  6. #6
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Cells Iteration

    No I don't need to see anything in particular outside of the address for Set CpyRNG.

    I keep forgetting about Debug.Print and that answers the question.

    Thanks for helping again...

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Cells Iteration

    Edited down.
    Last edited by JBeaucaire; 05-03-2010 at 08:11 PM.

  8. #8
    Registered User
    Join Date
    01-19-2006
    Posts
    28

    Re: Cells Iteration

    Woww.. it works!!
    Thanks for your help...

    Regards,
    Mut

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Cells Iteration

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1