Results 1 to 2 of 2

Macro needed to paste text value for specified number of times down to coulmn

Threaded View

  1. #1
    Forum Contributor
    Join Date
    04-09-2013
    Location
    india
    MS-Off Ver
    Excel 2010
    Posts
    176

    Macro needed to paste text value for specified number of times down to coulmn

    Hi to all,
    i have data like this
    text rows to repeat elements in row
    MB1 2 16
    MB2 3 3
    MB3 1 16
    MB4 4 15
    MB5 5 8

    i want to paste text for MB1 in column B like from MB1-1 to MB1-16 and MB1 2-1 to MB 2-16 because MB1 has 2 rows and 16 elements to repeat, for MB2 in cloumn B like MB2 1-1 to MB2 1-3 and MB2 2-1 to MB2 2-3 and MB2 3-1 to MB2 3-3 because MB has 3 rows and 3 elements to repeat like this i want to continue upto MB5

    I am expecting like this
    A B
    MB1 MB1 1-1
    .
    .
    .
    MB1 1-16
    MB1 2-1
    .
    .
    .
    MB1 2-16

    MB2 1-1
    .
    MB2 1-3

    MB2 2-1
    .

    MB2 2-3

    and i would like to continue this for the rest of text in column A .Here i tried with commond button simple and now i am in position to paste text in a given range but not the way i am expecting.
    here is my code
    Private Sub CommandButton1_Click()
    Dim Lastrow As Long
    Dim Cell As Range
    Dim i As Long
    Dim r As Long
     Lastrow = Range("A" & Rows.Count).End(xlUp).Row
    For Each Cell In Range("A1:A" & Lastrow)
     For i = 1 To 20
    r = r + 1
    Range("B" & r).Value = Cell.Value & " 1-" & Format(i, "00")
    Next i
    For i = 1 To 20
    r = r + 1
    Range("B" & r).Value = Cell.Value & " 2-" & Format(i, "00")
    Next i
    Next Cell
    End Sub
    I need to sovle this problem or needs editing to this VBA code to reach my objective. any help would be appreciated
    Thanking you
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro needed to search for text, highlight row, then cut & paste to another worksheet
    By BoyBri in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-20-2013, 07:17 AM
  2. Macro to Count the number of Rows between a text value that occurs mutliple times
    By AdamMoffitt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-06-2013, 11:34 AM
  3. [SOLVED] Simple copy and paste macro- Paste special help needed.
    By hernancrespo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-20-2012, 07:02 AM
  4. [SOLVED] Copy one value and paste it x number of times
    By jcb in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-12-2012, 04:52 PM
  5. Copy then paste/insert X number of times
    By Steve6386 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-04-2010, 04:53 PM

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