View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Altered pasting functionality

Hi JJ,

Am Fri, 25 Jan 2013 02:40:32 -0800 (PST) schrieb JJ:

Thanks Claus, your code is working on the exact example I stated above. But if I for example have "1" in C2 and "2" in C3 and I want to copy C2, select C3 and run the macro, it doesn't work.
Also - is it possible to use a solution without formating? I want the "/"-sign to be real.


then try (modify the columns to suit):

Sub Test()
Dim LRow As Long
Dim rngC As Range

LRow = Cells(Rows.Count, "B").End(xlUp).Row
Range("B1:B" & LRow).NumberFormat = "@"
For Each rngC In Range("B1:B" & LRow)
If rngC < "" And rngC.Offset(0, -1) = "" Then
rngC = rngC
ElseIf rngC = "" And rngC.Offset(0, -1) < "" Then
rngC = rngC.Offset(0, -1)
ElseIf rngC = "" And rngC.Offset(0, -1) = "" Then
rngC = ""
Else
rngC = rngC.Offset(0, -1) & "/" & rngC
End If
Next
End Sub

You have not to select cells. The code runs for Column A and Column B
and all the data that is in these columns.


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2