Results 1 to 17 of 17

Halp! Read cell for seperator, copy text, paste each segment to new workbook cell.

Threaded View

  1. #1
    Registered User
    Join Date
    07-31-2012
    Location
    California
    MS-Off Ver
    Excel 2003
    Posts
    31

    Halp! Read cell for seperator, copy text, paste each segment to new workbook cell.

    Hey all, I hate to be that guy that joins a forum and immediately posts a problem but I've been researching this issue for a few days now and can't figure it out.

    The user will enter image URLs into a single cell in a "Master" workbook. If there are more then one URL they must be separated by commas(,). When they hit the compile data macro button, I need it to 1) check if there is more then one URL, 2) (Assuming there is more then one URL) copy all text in the Master cell up to each comma, and 3) paste that text segment into incrementing cells in another workbook(the first string goes to column BE, the second to BF, etc, up to a max of six to BJ). This must be done for every cell in the column.

    Thoughts?

    EDIT: Thanks to Leith, this has been solved, here is the final code:
    Sub CopyURLs()
        
        Dim Cell As Range
        Dim DstRng As Range
        Dim DstWkb As Workbook
        Dim R As Long
        Dim RngEnd As Range
        Dim ScrRng As Range
        Dim SrcWkb As Workbook
        Dim URLs As Variant
            
            Set SrcWkb = Workbooks("Master_Template")
            Set DstWkb = Workbooks("Sears_Addon_Template")
            
            Set SrcRng = SrcWkb.Worksheets("Master Sheet").Range("A2")
            Set DstRng = DstWkb.Worksheets("Data Format").Range("BE2")
            
                Set RngEnd = SrcRng.Parent.Cells(Rows.Count, SrcRng.Column).End(xlUp)
                If RngEnd.Row < SrcRng.Row Then Exit Sub Else Set SrcRng = SrcRng.Parent.Range(SrcRng, RngEnd)
                
                For Each Cell In SrcRng
                    If Cell <> "" Then
                        URLs = Split(Cell, ",")
                        DstRng.Offset(R, 0).Resize(1, UBound(URLs) + 1).Value = URLs
                        R = R + 1
                    End If
                Next Cell
        
    End Sub
    Last edited by youngtusk87; 08-07-2012 at 02:57 PM.

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