Thread: Add to sheet
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
David Lloyd[_3_] David Lloyd[_3_] is offline
external usenet poster
 
Posts: 37
Default Add to sheet

The following code is one approach to this type of copy/merge/paste
operation. I would recommend using range names rather than specific cell
references. The code inserts a new column in the TimeSheet worksheet to
accommodate the two columns of data from the ClientNames worksheet. It then
merges the two columns, inserting a comma between the values. Finally, the
newly inserted column is deleted.

Sub CopyClientNames()
Dim i As Integer

Worksheets("TimeSheet").Activate
Range("C:C").Columns.Insert xlShiftToRight

Worksheets("ClientNames").Activate
Range("A12:B42").Copy

Worksheets("TimeSheet").Activate
Range("B10:B51").PasteSpecial xlPasteAll

Range("B10").Select
For i = 0 To Range("B10", "B51").Rows.Count - 1
If ActiveCell.Value < "" Then
ActiveCell.Value = ActiveCell.Value & "," & ActiveCell.Offset(0,
1).Value
End If
ActiveCell.Offset(1, 0).Select
Next i

Range("C:C").Columns.Delete xlShiftToLeft

Cells(1, 1).Select

End Sub

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


"oberon.black"
wrote in message
news:oberon.black.1v4eub_1126317918.3921@excelforu m-nospam.com...

I have a list of client names on a sheet called client names, I have
another sheet that I use to track time on I only want to create a code
on the time tracking sheet that will look on the client name sheet in
column A and B from row 12 to row 42 and then place those names in
column B row 10 - 51 of itself (track time sheet).

I know that on the client name sheet the client name is broken between
column A and B, however I would like for it to just place a comma
between the two in column B of the time track worksheet.

Thanx


--
oberon.black
------------------------------------------------------------------------
oberon.black's Profile:
http://www.excelforum.com/member.php...o&userid=26732
View this thread: http://www.excelforum.com/showthread...hreadid=466456