Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default need help concatenating, or maybe a macro would be better.

Have a part number listed in A column, it refers a new updated part number in
column C. I would like to concatenate it to a line of text. (or maybe a
macro would be better)

Column and numbers look like this:

Column A Column B Column C
Old number use new number New Number
01-261-0340 use new number 01-261-0340-01
95-0885 use new number 01-261-0340-01
95-0885-01 use new number 01-261-0340-01

I want to get it so it reads in a line of Text as:
01-261-0340-01 replaces 01-261-0340 , 95-0885 , 95-0885-01

Thanks for looking, and any help would be appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default need help concatenating, or maybe a macro would be better.


Since you have mutiple replacements it is bestt to use a simple macro
than complicated macros. the code assume the following

1) the orginal data is on sheet 1 in columns A - C
2) The original data has a header row. Data starts on row 2
3) The code sorts the original data by colum C and then column A
4) the results are put on sheet 2 starting in row 1



Sub GetReplacement()
Set SourceSht = Sheets("Sheet1")
Set DestSht = Sheets("Sheet2")

Newrow = 1
With Sheets("sheet1")
LastRow = .Range("A" & Rows.Count).End(xlUp).Row
'sort data by column C thenA
.Rows("1:" & LastRow).Sort _
header:=xlYes, _
key1:=.Range("C1"), _
order1:=xlAscending, _
key2:=.Range("A1"), _
order2:=xlAscending

RowCount = 2
OutputStr = ""
Do While .Range("A" & RowCount) < ""
Original = .Range("A" & RowCount)
If OutputStr = "" Then
Replacement = .Range("C" & RowCount)
OutputStr = Replacement & " replaces " & Original
Else
OutputStr = OutputStr & " , " & Original
End If

If .Range("C" & RowCount) < .Range("C" & (RowCount + 1)) Then
DestSht.Range("A" & Newrow) = OutputStr
Newrow = Newrow + 1
OutputStr = ""
End If
RowCount = RowCount + 1
Loop

End With

End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=145268

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default need help concatenating, or maybe a macro would be better.

In D1

= C1 & " replaces " & A1

In D2
= C1 & ", " & A2

then replicate D2 down



"Lakewoodsale" wrote:

Have a part number listed in A column, it refers a new updated part number in
column C. I would like to concatenate it to a line of text. (or maybe a
macro would be better)

Column and numbers look like this:

Column A Column B Column C
Old number use new number New Number
01-261-0340 use new number 01-261-0340-01
95-0885 use new number 01-261-0340-01
95-0885-01 use new number 01-261-0340-01

I want to get it so it reads in a line of Text as:
01-261-0340-01 replaces 01-261-0340 , 95-0885 , 95-0885-01

Thanks for looking, and any help would be appreciated.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Macro for concatenating multiple worksheet Scott Campbell[_2_] Excel Discussion (Misc queries) 1 March 29th 07 03:04 AM
concatenating Yosh Excel Discussion (Misc queries) 7 February 7th 07 09:03 PM
Concatenating a zero T De Villiers[_39_] Excel Programming 6 July 21st 06 03:44 PM
VB Macro for concatenating data... rivvorz[_2_] Excel Programming 1 April 13th 06 02:06 PM
Concatenating Metalteck New Users to Excel 10 May 4th 05 01:01 AM


All times are GMT +1. The time now is 08:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"