HELP!!!
I have run into a bit of an issue with part of my VBA code…
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o></o>
What it does:
1.) Looks at a data file that has been received from a device, a .csv file.
2.) It creates a new workbook, and then copies the info from the csv to the file.
3.) It renames a row
4.) Generates a month and year based on a column
5.) Concatenates several columns into one column
6.) It then deletes some unneeded columns
7.) It then saves data to a folder and closes the application
<o></o>
My problem is with the concatenate part…
The code currently is only concatenating the data for the first row, and then duplicating it down.
Also, and here is the real kicker it is not just duplicating it for the rows that have data, it is going all the way down to the very last cell in the sheet…
The output file should be 2K and now it is around 11MB!!!
What it Should do:
It should be searching for particular columns (ProdCode, ClientCode, Type, SubType, Month, Week, Year). Note my columns change order at times.
It should then take the data in each row of each column and concatenate it together in it's corresponding row, in a new column named Combo. Each value is seperated by a comma.
Here's a sample of what it should look like.
ProdCode,ClientCode,Type,SubType,Month,Week,Year
1174,EVAN11,3,A,5,1,11
<o></o>
<o></o>
<o></o>
<o></o>
<o>Here is my full code with sample data:</o>
https://rapidshare.com/files/401327348/EXCEL-MACRO.zip
Here is the code for the Concatenate section:<o> </o>
<o></o>
<o></o>
<o>
</o><o></o>
<o></o>
<o></o>
<o></o>
<o></o>
I have run into a bit of an issue with part of my VBA code…
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o></o>
What it does:
1.) Looks at a data file that has been received from a device, a .csv file.
2.) It creates a new workbook, and then copies the info from the csv to the file.
3.) It renames a row
4.) Generates a month and year based on a column
5.) Concatenates several columns into one column
6.) It then deletes some unneeded columns
7.) It then saves data to a folder and closes the application
<o></o>
My problem is with the concatenate part…
The code currently is only concatenating the data for the first row, and then duplicating it down.
Also, and here is the real kicker it is not just duplicating it for the rows that have data, it is going all the way down to the very last cell in the sheet…
The output file should be 2K and now it is around 11MB!!!
What it Should do:
It should be searching for particular columns (ProdCode, ClientCode, Type, SubType, Month, Week, Year). Note my columns change order at times.
It should then take the data in each row of each column and concatenate it together in it's corresponding row, in a new column named Combo. Each value is seperated by a comma.
Here's a sample of what it should look like.
ProdCode,ClientCode,Type,SubType,Month,Week,Year
1174,EVAN11,3,A,5,1,11
<o></o>
<o></o>
<o></o>
<o></o>
<o>Here is my full code with sample data:</o>
https://rapidshare.com/files/401327348/EXCEL-MACRO.zip
Here is the code for the Concatenate section:<o> </o>
<o></o>
<o></o>
<o>
Code:
</o:p>
<o:p>
<o:p>Sub Combo()</o:p>
<o:p></o:p>
<o:p>Dim Found1, Found2, Found3, Found4, Found5, Found6, Found7 As Range
Dim lastcol, delcol As Long
Dim Temp1, Temp2 As String
lastcol = Cells(1, Columns.Count).End(xlToLeft).Column
For delcol = lastcol To 1 Step -1
If Cells(1, delcol) = "Combo" Then _
Cells(1, delcol).EntireColumn.Delete
Next
Set Found1 = Rows(1).Find(what:="ProdCode", LookIn:=xlValues, lookat:=xlWhole)
Set Found2 = Rows(1).Find(what:="ClientCode", LookIn:=xlValues, lookat:=xlWhole)
Set Found3 = Rows(1).Find(what:="Type", LookIn:=xlValues, lookat:=xlWhole)
Set Found4 = Rows(1).Find(what:="SubType", LookIn:=xlValues, lookat:=xlWhole)
Set Found5 = Rows(1).Find(what:="Month", LookIn:=xlValues, lookat:=xlWhole)
Set Found6 = Rows(1).Find(what:="Week", LookIn:=xlValues, lookat:=xlWhole)
Set Found7 = Rows(1).Find(what:="Year", LookIn:=xlValues, lookat:=xlWhole)
Cells(1, Columns.Count).End(xlToLeft).Select
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = "Combo"
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = Evaluate(Found1.Offset(1, 0).Address(False, False) & "& "","" & " & Found2.Offset(1, 0).Address(False, False) _
& "& "","" & " & Found3.Offset(1, 0).Address(False, False) & "& "","" & " & Found4.Offset(1, 0).Address(False, False) _
& "& "","" & " & Found5.Offset(1, 0).Address(False, False) & "& "","" & " & Found6.Offset(1, 0).Address(False, False) _
& "& "","" & " & Found7.Offset(1, 0).Address(False, False))</o:p>
<o:p>Temp1 = ActiveCell.Address
ActiveCell.Offset(1, -1).Select
Selection.End(xlDown).Select
Temp2 = ActiveCell.Offset(0, 1).Address
Range(Temp1 & ":" & Temp2).Select
Selection.FillDown
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub</o:p>
<o:p></o:p>
</o><o></o>
<o></o>
Thank you to all of the forums members who have helped me put together this code!
<o></o><o></o>
<o></o>
<o></o>