Consulting

Results 1 to 3 of 3

Thread: copy cell and add extra cells with additional info.

  1. #1
    VBAX Regular
    Joined
    Jul 2010
    Posts
    15
    Location

    copy cell and add extra cells with additional info.

    Hi,

    Let me thank you first to forum contributors for all help posted here.
    I would like to write a VBA code to achive on attachement.

    Thanks
    Attached Files Attached Files

  2. #2
    VBAX Expert shrivallabha's Avatar
    Joined
    Jan 2010
    Location
    Mumbai
    Posts
    750
    Location
    This code should do it as you need.
    [VBA]Option Explicit
    Const e1 As String = ".com", e2 As String = ".co.uk", e3 As String = ".co.in"
    Public Sub UpdateDomain()
    Dim sDomain As String
    Dim vDomain As Variant
    Dim i As Integer
    Range("D2" & Range("D" & Rows.Count).End(xlUp).Row + 1).ClearContents
    For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
    vDomain = Split(Range("A" & i).Value2, ".")
    sDomain = vDomain(LBound(vDomain))
    Range("D" & Range("D" & Rows.Count).End(xlUp).Row + 1).Value = sDomain & e1
    Range("D" & Range("D" & Rows.Count).End(xlUp).Row + 1).Value = sDomain & e2
    Range("D" & Range("D" & Rows.Count).End(xlUp).Row + 1).Value = sDomain & e3
    Next i
    End Sub
    [/VBA]
    Regards,
    --------------------------------------------------------------------------------------------------------
    Shrivallabha
    --------------------------------------------------------------------------------------------------------
    Using Excel 2016 in Home / 2010 in Office
    --------------------------------------------------------------------------------------------------------

  3. #3
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    ...
    ...
    ...
    (sol. posted already)
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

Posting Permissions

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