PDA

View Full Version : copy cell and add extra cells with additional info.



dpatel
05-27-2011, 09:58 AM
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

shrivallabha
05-27-2011, 10:27 AM
This code should do it as you need.
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:D" & 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

mancubus
05-27-2011, 10:34 AM
...
...
...
(sol. posted already)