Results 1 to 6 of 6

Thread: [RESOLVED] Looping to next column

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    3

    Resolved [RESOLVED] Looping to next column

    I am looking to use a loop to populate the next column and am difficulties. The only way I am able to get it to work is to just past a new column each time, but that is making the order of the looping go backwards. Is there a way to move through columns and not have to insert a column? Any help is greatly appreciated. TIA
    Here is the code:

    VB Code:
    1. 'lets loop
    2. While dTempStart < dEnd
    3.  
    4.     'create a new column for the data
    5.     Sheets("Setup").Select
    6.     Columns("F:F").Select
    7.     Selection.Insert Shift:=xlToRight
    8.    
    9.     'plug the dates into the worksheet
    10.     Worksheets("Setup").Range("C3").Value = dTempStart
    11.     Worksheets("Setup").Range("C4").Value = dTempEnd
    12.    
    13.     'put worksheet output into the new column
    14.     Sheets("Setup").Select
    15.     Columns("C:C").Select
    16.     Selection.Copy
    17.     Columns("F:F").Select
    18.     Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
    19.         xlNone, SkipBlanks:=False, Transpose:=False
    20.     Columns("C:C").Select
    21.     Application.CutCopyMode = False
    22.      Range("E11").Select
    23.        
    24.     'setup for next iteration of the loop
    25.     dTempStart = dTempEnd + 1
    26.     dTempEnd = dTempEnd + interval - 1
    27. Wend
    Last edited by RobDog888; Apr 18th, 2006 at 11:04 PM. Reason: Added [vbcode] tags

Posting Permissions

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



Click Here to Expand Forum to Full Width