Results 1 to 7 of 7

Thread: Macro to fetch csv file and edit the file

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Junior Member
    Join Date
    Oct 2013
    Posts
    24
    Rep Power
    0
    Quote Originally Posted by littleiitin View Post
    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
    Attached Files Attached Files

Similar Threads

  1. Macro to fetch csv files
    By dhivya.enjoy in forum Excel Help
    Replies: 2
    Last Post: 10-21-2013, 05:44 PM
  2. Replies: 4
    Last Post: 06-20-2013, 04:25 PM
  3. Save Excel 2010 File In CSV Format VBA
    By mag in forum Excel Help
    Replies: 7
    Last Post: 01-08-2013, 07:16 PM
  4. Importing a csv File to a range
    By SDruley in forum Excel Help
    Replies: 21
    Last Post: 11-20-2012, 04:54 PM
  5. Save File In CSV Format VBA
    By Raj Kumar in forum Excel Help
    Replies: 3
    Last Post: 06-01-2011, 07:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •