Results 1 to 7 of 7

Thread: repeating one number

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    24
    Rep Power
    0

    repeating one number

    hi i want that in one column we have 24 of 1 then 24 of 2 then 24 of 3 up to 31 could you please send me the code

  2. #2
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    In C1: 24
    In C2: 31

    In C3 and copied down

    =if(rows(c$3:c3)<=$c$2,$c$1&" of "&rows(c$3:c3),"")

    is it what you are looking for ?
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  3. #3
    Junior Member
    Join Date
    Mar 2013
    Posts
    1
    Rep Power
    0
    Or, you can put the following line in C3 and copy down:
    =IF(ROWS(C$3:C3)<$C$1*$C$2,INT(ROWS(C$3:C3)/24+1),"")

  4. #4
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    14
    Or, in code, as requested...
    Code:
    Sub InsertThirtyOneSetsOfTwentyFourEach()
      Dim X As Long, Z As Long, Index As Long, Nums(1 To 744, 1 To 1)
      Const StartCell As String = "A1"
      For X = 1 To 31
        For Z = 1 To 24
          Index = Index + 1
          Nums(Index, 1) = X
        Next
      Next
      Range(StartCell).Resize(744) = Nums
    End Sub
    Note: Adjust the starting cell address (as shown in red above) to match your actual requirements.
    Last edited by Rick Rothstein; 12-18-2014 at 09:13 PM.

  5. #5
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    13
    or

    Code:
    Sub M_snb()
        [A1].Resize(24 * 31).Name = "snb_002"
        [Snb_002] = [index(int((row(snb_002)-1)/24)+1,)]
    End Sub

  6. #6
    Junior Member
    Join Date
    May 2013
    Posts
    2
    Rep Power
    0
    Assumed your data on A1 and down, put this on B1 and copied down:

    =A1&" Of "&COUNTIF($A$1:A1,A1)

  7. #7
    Junior Member
    Join Date
    Aug 2014
    Posts
    10
    Rep Power
    0
    Code:
    Sub Insert24x31()
    With Range("A1:A744")
        .Formula = "=INT((ROW()-1)/24)+1"
        .Value = .Value
    End With
    End Sub

Similar Threads

  1. Replies: 7
    Last Post: 07-11-2013, 11:47 PM
  2. Replies: 3
    Last Post: 03-31-2013, 06:18 AM
  3. Adding specfic number to a available number in previous cell.
    By Rajesh Kr Joshi in forum Excel Help
    Replies: 2
    Last Post: 03-02-2013, 01:55 AM

Posting Permissions

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