Results 1 to 6 of 6

Loop fails on 2nd iteration

Threaded View

  1. #1
    Forum Contributor
    Join Date
    07-11-2010
    Location
    Minneapolis, USA
    MS-Off Ver
    Excel 2016
    Posts
    308

    Loop fails on 2nd iteration

    My loop works for the first J but fail on the 2nd iteration and I can not figure out why

    Thanks


    
    Sub RCFLB_n()
    
        RCFLB "XXX",  Array("What", "Where", "Why", "How")
    
    End Sub
    Sub RCFLB(shtName As String,Optional HNarr As Variant = "Col1")
    Dim arrData() As Variant, arrReturnData() As Variant, CN As Variant
    Dim ws As Worksheet
    Dim LR As Long, LC As Long
    Dim I As Long, J As Long
    
    Set ws = ThisWorkbook.Sheets(shtName)
    
    'Array of Column numbers coresponding to Header names
    CN = CHTCN(shtName, HNarr)
    
    With ws
         LR = .Cells.Find("*", [a1], , , xlByRows, xlPrevious).Row
    End With
    ReDim arrReturnData(1 To LR, 1 To 1)
    
      For J = 0 To UBound(CN)
      Erase arrData
      arrData = ws.Range(ws.Cells(1, CN(J)), ws.Cells(LR, CN(J))).Value
      
      MsgBox arrData(1, CN(J))
      
    Next J
    
       'Stuff
    
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Continue next iteration of For loop
    By Excel_vba in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-22-2013, 02:09 AM
  2. Loop Array Iteration and Processing
    By Bigced_21 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-01-2010, 11:16 AM
  3. Selection not updating after 1st iteration in a For Each loop
    By Excel_vba in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-18-2009, 09:19 PM
  4. For Loop STOPS at Random Iteration!
    By wjoc1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-18-2007, 09:58 AM
  5. Advancing to the next iteration of a loop?
    By Maury Markowitz in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-02-2005, 01:06 PM

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