+ Reply to Thread
Results 1 to 4 of 4

Re-number column from 1

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2019
    Posts
    756

    Re-number column from 1

    Hi all,

    I am trying to renumber a column in my worksheet from 1 downwards (i.e. 1 to the last cell in column A) I have tried with the code below which clears the contents in Column A, puts a 1 in A10 and then does a flashfill:

    Sub Procedure1()
    
    Sheets("Co-location").Select
    Range("A10:A1048576").ClearContents
    Range("A10").Select
        ActiveCell.FormulaR1C1 = "1"
        Range("A10").Select
        Range("$A$10").FlashFill
        
    End Sub
    But it does not number then sequentially, i.e. 1 2 3 4 5 6 7 and so on

    I have attached a workbook to show how my data looks etc

    Any ideas why this is not working?

    Many thanks,

    Chris
    Attached Files Attached Files

  2. #2
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Re-number column from 1

    Please try

    PHP Code: 
    Sub Fills()

    With Sheets("Co-location").[a10]
        .
    Value 1
        
    .AutoFill .Resize(.CurrentRegion.Rows.Count 1), 2
    End With

    End Sub 
    Attached Files Attached Files

  3. #3
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Re-number column from 1

    Alternative:

    Public Sub RenumberColumn()
    
    With Sheets("Co-location")
        With .Range(.Range("A10"), .Cells(.Rows.Count, "A").End(xlUp))
            .Formula = "=ROW()-9"
            .Value = .Value
        End With
    End With
    
    End Sub
    WBD
    Office 365 on Windows 11, looking for rep!

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,336

    Re: Re-number column from 1

    With Range("A10:A" & Cells(Rows.Count, 2).End(xlUp).Row)
        .Value = Evaluate("=Row(" & .Address & ")-9")
    End With
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

+ 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: 2
    Last Post: 03-12-2020, 05:31 PM
  2. [SOLVED] Search for number in Column A, then upload image in next column if number does not exist.
    By tinytwo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-02-2015, 10:22 AM
  3. [SOLVED] If number in Column A matches number in column B - Copy B cell and adjacent cells ?
    By BPSJACK in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-16-2014, 12:30 PM
  4. Replies: 10
    Last Post: 10-30-2013, 07:29 PM
  5. Replies: 1
    Last Post: 06-10-2013, 07:08 PM
  6. Find highest revision number in one column of a item number in another column
    By Tasiast in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-01-2013, 01:03 PM
  7. Lookup largest number in a column treating negative number as postive number
    By xWiZardx in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-17-2010, 08:09 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