+ Reply to Thread
Results 1 to 4 of 4

New to VBA, need help with For Loop

  1. #1
    Registered User
    Join Date
    08-14-2017
    Location
    San Diego, CA
    MS-Off Ver
    2016
    Posts
    1

    New to VBA, need help with For Loop

    Hello,

    I'm trying to create a program that will move a column from one sheet to another based on the header in the column. Depending on the report that I pull, this column can change location (it will always be the first row) so I tried creating a For Loop to move through the columns but when I run the program, nothing happens. I know it has to do with the For Loop because if I specify the cell that the word "DATE" is in, everything moves just fine. Here's what I have:
    Please Login or Register  to view this content.
    End Sub

    Thanks in advance!

  2. #2
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: New to VBA, need help with For Loop

    Hi jazzyvba, the For Loop doesn't require you to have the colnum = colnum + 1. Try removing that.

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: New to VBA, need help with For Loop

    Hi jazzyvba and welcome to the forum,

    Here is some jazzy update to your vba. See if it makes sense.

    Please Login or Register  to view this content.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: New to VBA, need help with For Loop

    You don't really need a loop to find the column that has the header 'DATE', you could just use Application.Match.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] (Beginner help) For loop inside do loop that displays information from reference sheet.
    By lediable007 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-08-2016, 03:20 PM
  2. [SOLVED] Auto email loop with formatted table data breaking on second loop VBA
    By Who_else in forum Excel General
    Replies: 6
    Last Post: 03-24-2016, 06:22 AM
  3. [SOLVED] VBA to loop within a loop of multiple blocks of data (currentregion) ... Expert needed
    By Jim885 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-20-2016, 08:28 PM
  4. Find function in nested loop breaking down - not on first time through loop
    By adamstarr12 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-07-2014, 04:59 PM
  5. [SOLVED] Copy dynamically changing column and Paste using VBA Loop (Loop within Loop)
    By nixon72 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-12-2013, 12:46 PM
  6. Why did an inner loop variable start overwriting the outer loop range suddenly?
    By 111StepsAhead in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-16-2012, 03:24 PM
  7. Replies: 0
    Last Post: 07-20-2010, 11:42 AM

Tags for this Thread

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