+ Reply to Thread
Results 1 to 3 of 3

Delete rows in another workbook

  1. #1
    Registered User
    Join Date
    03-10-2022
    Location
    Philippines
    MS-Off Ver
    2016
    Posts
    2

    Delete rows in another workbook

    Hi experts,

    I'm a newbie in VBA so would appreciate it from the bottom of my heart if someone would help me with this.

    What I'm trying to do is Convert a number of excel files to CSV and delete the rows headers then save them to a specific folder.

    Now, I figured out how to convert excel to CSV and transfer them to a folder but I'm unable to solve how to delete rows before it is saved to a folder.

    Here's the script that I did.

    Private Sub CommandButton1_Click()
    Dim wb As Workbook

    Set wb = Workbooks.Open(Worksheets("Sheet1").Cells(1, 1).Value)

    wb.SaveAs Filename:="pathdestination\test1csv.csv", FileFormat:=xlCSV, CreateBackup:=False

    wb.Close savechanges:=False

    wb.Rows(1).Delete

    MsgBox ("Converted to CSV")

    Dim wb2 As Workbook

    Set wb2 = Workbooks.Open(Worksheets("Sheet1").Cells(3, 1).Value)

    wb2.SaveAs Filename:="pathdestination\test2csv.csv", FileFormat:=xlCSV, CreateBackup:=False

    wb2.Close savechanges:=False

    MsgBox ("Converted to CSV")


    End Sub

    I hope someone can help, please.

    THank you!
    -JerryM-

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,659

    Re: Delete rows in another workbook

    Quote Originally Posted by JerryM0124 View Post
    ... but I'm unable to solve how to delete rows before it is saved to a folder.
    Your code already has a delete row line in it. Move it after you open the file and before you SaveAs the file. The syntax would be...
    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    03-10-2022
    Location
    Philippines
    MS-Off Ver
    2016
    Posts
    2

    Re: Delete rows in another workbook

    Hi AlphaFrog,

    You are awesome! it works like a charm.

    Thank you so much!!!!!
    -JerryM-

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] vba delete rows in another workbook
    By carrollm in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-06-2020, 12:36 AM
  2. [SOLVED] delete blank rows in new Workbook with VBA
    By QuantumSquirrel in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 04-24-2020, 01:32 PM
  3. Replies: 2
    Last Post: 08-07-2017, 02:37 PM
  4. Replies: 1
    Last Post: 08-07-2017, 01:27 PM
  5. [SOLVED] Delete Rows in entire workbook.
    By jhall488 in forum Excel Programming / VBA / Macros
    Replies: 54
    Last Post: 11-12-2012, 12:49 PM
  6. Delete rows from another workbook
    By psatkar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-12-2006, 05:28 AM
  7. delete empty rows in workbook
    By TooN in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-10-2006, 06:25 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1