Copy and Pasting- is there a short cut?

JenChism

New Member
Joined
Sep 11, 2011
Messages
2
I have an excel sheet that has headers columns for company name (A1), company address (B1), company website (C1) and email addresses (D1). The last field (D1) contains multiple addresses which I have been able to extract into additional columns to the right of the exisiting columns (the number of additional columns will vary row to row depending how many emails were in the (D1) column). So each line now shows the company name in A1 with each field in its own cell to the right with the emails now each having their own cell. I have an entire speadsheet set up this way. What I need to know is if there is a way to get all of the emails currently showing on the same row to be dropped into a new row and get the company information from A1-C1 (company name, address and website) be included on the new row?
Example:
ABC Co. 123 River Rd. www.abc.com jb@abcco.com; jc@abc.com, j2@abc.com
I need to get it to look like this:
ABC Co. 123 River Rd. www.abc.com jb@abcco.com
ABC Co. 123 River Rd. www.abc.com jc@abc.com
ABC Co. 123 River Rd. www.abc.com j2@abc.com
Is there way for me to do this without copying and pasting for hours?
Thank You!
[E-mail address removed by moderator]
251-253-4099
 
Last edited by a moderator:

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hello JenChism,

This macro will separate will copy the company information, web site, and a single email from the source sheet ("Sheet1") to a new row on the destination sheet ("Sheet2"). You can change the sheet names in the macro to what you will using. Copy and paste this macro code into a new VBA module in your workbook.

NOTE: The macro expects the email addresses to be separated by a semi-colon.

Code:
' Poster:  JenChism
' Thread:  http://www.mrexcel.com/forum/showthread.php?t=578025
' Written: September 11, 2011
' Author:  Leith Ross

Sub OneEmailPerRow()

  Dim Cell As Range
  Dim CompanyInfo As Variant
  Dim DstRng As Range
  Dim DstWks As Worksheet
  Dim Emails As Variant
  Dim I As Long
  Dim R As Long
  Dim SrcRng As Range
  Dim SrcWks As Worksheet
  
  ' Choose the Source and Destination sheet names
    Set SrcWks = Worksheets("Sheet1")
    Set DstWks = Worksheets("Sheet2")
    
    ' Automatically setup the Source and Destination ranges
      Set SrcRng = SrcWks.Range("A1").CurrentRegion
      Set DstRng = DstWks.Range("A1")
      
      ' Split the Source data and emails and copy to the Destination
        For Each Cell In SrcRng.Columns(1).Cells
          CompanyInfo = Cell.Resize(1, 3).Value
          Emails = Split(Cell.Offset(0, 3), ";")
          ' Put Company info and a single email on a single row
            For I = 0 To UBound(Emails)
              DstRng.Offset(R, 0).Resize(1, 3).Value = CompanyInfo
              DstRng.Offset(R, 3).Value = Emails(I)
              R = R + 1
            Next I
        Next Cell
              
End Sub
 
Last edited:
Upvote 0
Try this, lots of hard coding, operates on the active sheet:
Code:
Sub bah()
LR = Cells(Rows.Count, "A").End(xlUp).Row
For rw = LR To 2 Step -1
    NewRowsNeeded = Cells(rw, Columns.Count).End(xlToLeft).Column - 4
    If NewRowsNeeded > 0 Then
        Rows(rw + 1).Resize(NewRowsNeeded).Insert
        Cells(rw, 1).Resize(, 3).Copy Cells(rw + 1, 1).Resize(NewRowsNeeded)
        Cells(rw, "E").Resize(, NewRowsNeeded).Copy
        Cells(rw + 1, "D").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
        Cells(rw, "E").Resize(, NewRowsNeeded).ClearContents
    End If
Next rw
End Sub
 
Last edited:
Upvote 0
Thank you very much for the insight, I will repost asap to let you know if it worked. I am a novice at macros, but think I know how to use the info you guys gave me. I am excited that it IS possible to do this. Thank you both for your responses!
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,734
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top