+ Reply to Thread
Results 1 to 3 of 3

Loop through sheets with specific Name starting with AIPRSU to number all lines in colum M

  1. #1
    Registered User
    Join Date
    06-04-2022
    Location
    Prague
    MS-Off Ver
    Office 365
    Posts
    6

    Loop through sheets with specific Name starting with AIPRSU to number all lines in colum M

    Hi,

    I need to loop through all sheets whose name starts with AIPRSU to obtain a sequential numbering in all filled rows in column M starting from row 2. Attached is the file for your reference.

    I have created a macro named "Loop_line_numbers" for this purpose, but I get some coding errors, apologies for my poor coding skills.


    Thanks
    F
    Attached Files Attached Files

  2. #2
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    8,333

    Re: Loop through sheets with specific Name starting with AIPRSU to number all lines in col

    Within a ws sheet, you need to set "ws. range" not "range" only, to tell excel that range belongs to specific ws, not active sheet
    HTML Code: 
    Sub Loop_line_numbers()
    Dim ws As Worksheet
    Dim LastRow As Long
    Dim counter As Long
    For Each ws In ActiveWorkbook.Worksheets
        If ws.Name Like "AIPRSU*" Then
            LastRow = ws.Range("B" & Rows.Count).End(xlUp).Row
            For counter = 2 To LastRow
                ws.Range("M" & counter).Value = counter - 1
            Next counter
        End If
    Next ws
    End Sub

  3. #3
    Registered User
    Join Date
    06-04-2022
    Location
    Prague
    MS-Off Ver
    Office 365
    Posts
    6

    Re: Loop through sheets with specific Name starting with AIPRSU to number all lines in col

    Thank you very much! This solution worked perfectly!

+ 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. Replies: 5
    Last Post: 06-05-2022, 09:24 PM
  2. [SOLVED] Extracting lines starting with a certain number in a cell.
    By Carsten211 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 04-28-2022, 07:45 AM
  3. Loop through a set number of sheets starting with inputted initial sheet name
    By declan1983 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-17-2022, 12:01 AM
  4. Starting Week number by specific time
    By naiconn in forum Excel General
    Replies: 5
    Last Post: 12-03-2014, 08:37 AM
  5. Replies: 2
    Last Post: 11-28-2013, 03:13 PM
  6. [SOLVED] Function that looks for a number that is in a colum next to a specific date.
    By kilomanjaro4 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-20-2013, 11:57 AM
  7. Deletion of excel lines starting from specific text
    By meetvivek72 in forum Excel General
    Replies: 8
    Last Post: 07-24-2012, 09:29 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