Results 1 to 6 of 6

VBA Question about using For Each loop

Threaded View

  1. #1
    Registered User
    Join Date
    02-05-2014
    Location
    Canada
    MS-Off Ver
    Excel 2013
    Posts
    29

    VBA Question about using For Each loop

    Hey!

    So I have a big sheet that I'm working on that is using this code to pull items over from one sheet to the next which works great until I change some values in it and I'm not sure why.

        
        Set Source = ActiveWorkbook.Worksheets("CSV")
        Set Target = ActiveWorkbook.Worksheets("CSV2")
    
        j = 1
        For Each c In Source.Range("C1:C1000")
            If c >= 1 Then
               Source.Range("A" & c.Row & ":C" & c.Row).Copy
               Target.Rows(j).PasteSpecial xlPasteValues
            
               j = j + 1
            End If
        Next c
    So when I change it to source.range to A:D instead of A:C, it will paste repetitively for thousands of more columns past A:D. So E:H will have the data too, etc for thousands of rows. Just wondering what I'm doing wrong there!

    Thanks!!!


    [/CODE]
    Last edited by jamief; 12-11-2019 at 06:33 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Question Regarding a For Loop
    By unit285 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-25-2017, 04:26 PM
  2. [SOLVED] For next loop question.
    By HerryMarkowitz in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-29-2014, 04:08 PM
  3. Loop question..
    By calvinle in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-12-2014, 12:40 AM
  4. [SOLVED] Loop within a Loop Question
    By vexel77 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-26-2013, 11:26 AM
  5. VBA loop question
    By JediMind in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 04-29-2010, 04:40 PM
  6. For next loop question
    By hydrojoe11 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-21-2008, 11:32 AM
  7. For...Next Loop question
    By CWatsonJr in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 09-12-2005, 04:26 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