ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   concatenate values / convert to csv help (https://www.excelbanter.com/excel-programming/298564-concatenate-values-convert-csv-help.html)

Will[_7_]

concatenate values / convert to csv help
 
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,


Tom Ogilvy

concatenate values / convert to csv help
 
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).V alue = _
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

--
Regards,
Tom Ogilvy

"Will" wrote in message
...
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,




Will[_7_]

concatenate values / convert to csv help
 
Thank you very much Tom for the prompt reply. Your
solution is exectly does what I was asking for.

Thanks again,

Will
-----Original Message-----
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

--
Regards,
Tom Ogilvy

"Will" wrote in

message
...
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,



.



All times are GMT +1. The time now is 07:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com