concatenate values / convert to csv help

W

Will

Hi all,

I have a table with only one column which is serial#.

Could you help me to create a macro that will
concatenate "prd-" text with serial# value and save the
results as csv file in designated location. I am just
learning VBA.
The range in serial# colum is not static, it could change
every week. So the range like a1:a100 can not be assigned.

Thanks a lot and hugs to all,
 
T

Tom Ogilvy

Dim sh as Worksheet
Dim rng as Range, rng1 as Range
set sh = Activesheet
set rng = sh.Range(sh.Cells(1,1),Sh.Cells(1,1).End(xldown))
workbooks.Add
activesheet.Range("a1").Resize(rng.rows.count,1).Value = _
rng.Value
set rng1 = ActiveSheet.Range("A1").CurrentRegion
for each cell in rng1
cell.Value = "prd-" & cell.Value
Next
activeWorkbook.SaveAs FileName:="C:\files\file1.csv", _
FileFormat:=xlCsv
activeworkbook.Close SaveChanges:=False
 
W

Will

Thank you very much Tom for the prompt reply. Your
solution is exectly does what I was asking for.

Thanks again,

Will
 
Top