PDA

View Full Version : Repeating a string using VBA button



Alexan
04-24-2016, 02:29 AM
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



15993

snb
04-24-2016, 03:20 AM
Are you from India ?

p45cal
04-24-2016, 01:40 PM
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

jolivanes
04-24-2016, 08:51 PM
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