
Originally Posted by
littleiitin
Change Below lines in Red section accordingly -------------------------
Code:
strCSV_1_Columns = "A:C,E,G,I" ' Let Say Column A to C and Columns E, G, and I
strCSV_2_Columns = "D,F,H,J:L" ' Let Say Columns D,F,H and Columns J to L
Hi Littleiitin,
I could not see any code in red in your above reply.
I wanted to add some more new columns to csv which are not present in the user's excel sheet.
i tried the below code, which added the column names, now to add values to those columns i am stuck up with. Also i wanted to add these values to all the rows in csv for eg in the attached csv IS_ACTIVE is the column which i added extra using my modified code below, and i wanted to fill the default value as Y till the rows it has data in it.
Code:
strFirstCSVName = "First"
strSecondCSVName = "Second"
strFirstTable = "RATE_OFFERING"
strSecondTable = "RATE_GEO"
FirstTable_Col1 = "IS_ACTIVE"
strCSV_1_Columns = "A:E" ' Let Say Column A to C and Columns E, G, and I
strCSV_2_Columns = "F:G,I" ' Let Say Columns D,F,H and Columns J to L
strSaveLocation = "C:\Users\13124\Desktop\"
'''''''''===============================================
Set wksAct = ActiveSheet
Set wbkNew = Workbooks.Add(1)
With wksAct
Set rngUsedRng = .UsedRange
lngLastRow = rngUsedRng.Rows.Count
strRange = MakeRange(strCSV_1_Columns)
.Range(strRange).Copy
wbkNew.Sheets(1).Range("A1").PasteSpecial xlPasteValuesAndNumberFormats
wbkNew.Sheets(1).Rows(1).Insert
' wbkNew.Sheets(1).Columns(1).Insert
' wbkNew.Sheets(1).Rows(1).Insert
wbkNew.Sheets(1).Cells(1).Value = strFirstTable
wbkNew.Sheets(1).Rows(2).Cells(6).Value = FirstTable_Col1
Please advice
Bookmarks