Consulting

Results 1 to 4 of 4

Thread: Repeating a string using VBA button

  1. #1
    VBAX Newbie
    Joined
    Apr 2016
    Posts
    1
    Location

    Repeating a string using VBA button

    Hello

    I am new to this VBA and I need a code that repeats each symbol 4 times (with one line space in between except for the header line )

    As seen in the below picture.


    Thanks in advance for your help

    ------------------------------------------------------------------------------------------------------

    Private Sub CommandButton1_Click()

    ...........code ................


    End Sub



    vba command bottun.JPG

  2. #2
    snb
    Guest
    Are you from India ?

  3. #3
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,893
    Try something along the lines of:
    Private Sub CommandButton1_Click()
    Set Destn = Range("H3") ' adjust starting cell to suit.
    For Each cll In Range("A2:A" & Rows.Count).SpecialCells(xlCellTypeConstants, 2).Cells
      Destn.Resize(4).Value = cll.Value
      Set Destn = Destn.Offset(5)
    Next cll
    End Sub
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  4. #4
    Just for the heck of it. Another way
    Sub Or_Maybe_This()
        Dim j As Long
        For j = 3 To Cells(Rows.Count, 2).End(xlUp).Row
            Cells(Cells(Rows.Count, 4).End(xlUp).Row, 4).Offset(2).Resize(4).Value = Cells(j, 2).Value
        Next j
    End Sub

Posting Permissions

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