+ Reply to Thread
Results 1 to 26 of 26

Autofill numbers using Macro

  1. #1
    Registered User
    Join Date
    04-01-2008
    Posts
    54

    Autofill numbers using Macro

    Hi All,

    I have recorded a macro and it is working fine

    My query is while the macro is running a column is inserted and numbers are autofilled

    Please Login or Register  to view this content.
    But I want as solution like if there is data only till B24 then It should fill upto A2:A24
    Last edited by DonkeyOte; 01-21-2010 at 06:44 AM. Reason: tags added

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Autofill numbers using Macro

    hi kamalthakur
    add some code tags and get the answer as is quite straight forward
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Autofill numbers using Macro

    Listen to Pike. Do that first and then use this code

    Range("A2:A61") can be changed in a dynamic range

    Please Login or Register  to view this content.
    Last edited by rwgrietveld; 01-21-2010 at 05:24 AM.
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

  4. #4
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Autofill numbers using Macro

    try this

    Please Login or Register  to view this content.
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  5. #5
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Autofill numbers using Macro

    dude's still no tags!! no tags no posts

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Autofill numbers using Macro

    Guys, the fact that a non Mod requested an OP modify their post in line with the rules does not make one iota of difference regards to posting on a thread thereafter.

    You (rwg, c) both know the rules well enough yourselves ... please consider this a (final) friendly reminder of that fact ...

    If I see a non-Mod inform re: rule I see no reason to do likewise (for fear of overwhelming OP) - however on that basis I expect others to use their own judgement and not post either until rule is complied with.

    Please do not create extra work for the Mods by ignoring the postings of your fellow members to the extent that Mods are compelled to duplicate the warning ... we'd rather spend our time answering than administering.
    Last edited by DonkeyOte; 01-21-2010 at 05:33 AM. Reason: reworded

  7. #7
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Autofill numbers using Macro

    Hi kamalthakur
    If you are unsure on how to add code tags click on the link in my signature
    as the answer is still quite straight forward

  8. #8
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Autofill numbers using Macro

    my take
    Please Login or Register  to view this content.

  9. #9
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Autofill numbers using Macro

    Pike, now you break your own rule...

    So that I can stop watching this thread I've added the tags... please refrain from these practices going forward.

  10. #10
    Registered User
    Join Date
    04-01-2008
    Posts
    54

    Re: Autofill numbers using Macro

    Thank you for the response I was away from my system.

    I have copied the code and pasted and it is working but the number increment is not happening

    Any clue on this

  11. #11
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Autofill numbers using Macro

    will do DonkeyOte had a rush to the brain
    Hi kamalthakur
    whats the formula in A2?

  12. #12
    Registered User
    Join Date
    04-01-2008
    Posts
    54

    Re: Autofill numbers using Macro

    Below is the code you gave to me

    With Range("A2")
    .AutoFill Destination:=Range("A2:A" & Cells(Rows.Count, 2).End(xlUp).Row)
    End With

    there is no formula when i run the macro from cell A2 the numbers should start like a2=1 a3=2 this should increase till there is a value in B column

  13. #13
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Autofill numbers using Macro

    Now kamalthakur
    I have the solution in my hot little hand but for the answer, so it wont go past 24 row ,you must MUST add the code tags to the last post
    eg

    [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code]

  14. #14
    Registered User
    Join Date
    04-01-2008
    Posts
    54

    Re: Autofill numbers using Macro

    Ok Pike below is the code

    {code}
    Range("A2").Select
    ActiveCell.FormulaR1C1 = "1"
    Range("A3").Select
    ActiveCell.FormulaR1C1 = "2"
    Range("A2:A3").Select
    With Range("A2")
    .AutoFill Destination:=Range("A2:A" & Cells(Rows.Count, 2).End(xlUp).Row)
    End With
    {code}

  15. #15
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Autofill numbers using Macro

    HTML Code: 

  16. #16
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Autofill numbers using Macro

    close but no cigar replace the first { code} with [ code] and the second {code} with [/code]

  17. #17
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Autofill numbers using Macro

    its like looking into a mirror ...... great minds ....

  18. #18
    Registered User
    Join Date
    04-01-2008
    Posts
    54

    Re: Autofill numbers using Macro

    Please Login or Register  to view this content.

  19. #19
    Valued Forum Contributor rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Autofill numbers using Macro

    Edit. reason: No added value
    Last edited by rwgrietveld; 01-21-2010 at 12:21 PM.

  20. #20
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Autofill numbers using Macro

    beautiful
    Please Login or Register  to view this content.

  21. #21
    Registered User
    Join Date
    04-01-2008
    Posts
    54

    Re: Autofill numbers using Macro

    Fine Please delete it i never new a new person if doesn't know how use the tags this is not the way to respond him

  22. #22
    Registered User
    Join Date
    04-01-2008
    Posts
    54

    Re: Autofill numbers using Macro

    You mean to say that it will take upto 24 fourth row
    My query is if cell B70 has data it should increment till B70
    so whenever i run the macro it should first check till which in B column the data is and then it should increment the number in first column

  23. #23
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Autofill numbers using Macro

    Hi kamalthakur
    dont be like that, there are a few rules .. which should have to read .. it explains the tags
    and how once you have so many post that you need to add the tags
    Look at my Public Profile I've had four infractions .. no sweat .. It very friendly here
    please dont be offended. your problem was fun to solve and when you hang around for a while you will be answering questions and will laugh when you remember your first couple of posts
    the mod are pretty good they let the members answer the posts and only come in if they are off the mark.
    Yes there are rules but they help keep order for those who come after searching for similar questions
    the tag are important and help make the code easier to read.

    its no biggie you now know how to add the tags: now - you did better that me when i first started

  24. #24
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Autofill numbers using Macro

    my bad
    Please Login or Register  to view this content.
    Last edited by pike; 01-21-2010 at 08:49 AM.

  25. #25
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Autofill numbers using Macro

    no RC code are better \
    Please Login or Register  to view this content.
    Last edited by pike; 01-21-2010 at 09:14 AM. Reason: added Range("A1").FormulaR1C1 = "=ROW(RC)+1"

  26. #26
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Autofill numbers using Macro

    Hi kamalthakur
    Please Login or Register  to view this content.
    dont forget
    To mark your thread solved do the following:
    - Go to the first post
    - Click edit
    - Click Advance
    - Just below the word "Title:" you will see a dropdown with the word No prefix.
    - Change to Solve
    - Click Save

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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