Hi all,
I have a working code where when I am importing sheet from multiple workbooks, it will add a column to include the first 6 characters of the filename. This code works perfectly fine when there are data in all the columns/rows
Now the problem I am facing importing is the sheet has at least 20 columns. Some columns are blank with no data like column E and F. When I run the code, it recognizes E as the end of the row and adds a new column with the filename. How do I fix that? The new column should be at the end of the 20 column.
Hope I made sense.
I have a working code where when I am importing sheet from multiple workbooks, it will add a column to include the first 6 characters of the filename. This code works perfectly fine when there are data in all the columns/rows
VBA Code:
'Adding last column for the first 6 characters of the file name
ThisWorkbook.Sheets("Master").Activate
desWS.Cells(desWS.Rows.Count, "A").End(xlUp).End(xlToRight).Offset(0, 1).End(xlUp).Offset(1, 0).Select
ActiveCell.FormulaR1C1 = Left(strExtension, 6)
Selection.Copy
Selection.Offset(0, -1).Select
Selection.End(xlDown).Select
Selection.Offset(0, 1).Select
Range(Selection, Selection.End(xlUp)).Select
ActiveSheet.Paste
Now the problem I am facing importing is the sheet has at least 20 columns. Some columns are blank with no data like column E and F. When I run the code, it recognizes E as the end of the row and adds a new column with the filename. How do I fix that? The new column should be at the end of the 20 column.
Hope I made sense.