+ Reply to Thread
Results 1 to 5 of 5

Creating loop by VBA

  1. #1
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Creating loop by VBA

    Hi,
    I need your help with quite a simple loop. Please see attachment.
    For each column the the series 1 to 14 has to start one row below - using VBA.
    Thanks
    Attached Files Attached Files
    Please * if you like the answer

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Creating loop by VBA

    Give this code a try.

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    12-30-2012
    Location
    Israel
    MS-Off Ver
    2007, 2016
    Posts
    642

    Re: Creating loop by VBA

    Thank you very much!

  4. #4
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,401

    Re: Creating loop by VBA

    Here is another macro for you to consider...
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-22-2020
    Location
    Pune India
    MS-Off Ver
    MS Office 2019
    Posts
    1

    Re: Creating loop by VBA

    This code is little dynamic:

    Sub fillNumbersByCols()

    Dim worksheetActive As Worksheet
    Dim colNumber, rowNumber, rowPointer As Integer, i As Integer
    Dim startNumber, endNumber As Integer
    Dim startRowNumber, startColNumber As Integer
    'Initiate veriables
    startNumber = 1
    endNumber = 10
    startRowNumber = 2
    startColNumber = 2

    Set worksheetActive = ThisWorkbook.ActiveSheet

    With worksheetActive

    colNumber = startColNumber
    rowPointer = startRowNumber - 1

    Do While .Cells(rowPointer, colNumber).End(xlUp).Value <> ""
    For i = startNumber To endNumber
    .Cells(rowPointer + i, colNumber).Value = i
    Next i
    rowPointer = rowPointer + 1
    colNumber = colNumber + 1
    Loop

    End With

    Set worksheetActive = Nothing

    End Sub

+ 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. Creating Loop
    By vinod2802 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2015, 09:31 AM
  2. Creating on loop
    By 13lack13lade in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-20-2013, 06:23 AM
  3. [SOLVED] Help with creating a loop within vba
    By christopherjward in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-23-2013, 07:05 PM
  4. Creating a Do Until loop
    By pld in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-21-2010, 02:31 PM
  5. On creating a loop
    By joelhuang in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-22-2009, 04:52 AM
  6. Need Help With Creating A Loop
    By zero635 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-29-2005, 04:05 PM
  7. [SOLVED] Creating a loop
    By Ibuprofen in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-26-2005, 12:05 AM

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