Consulting

Results 1 to 4 of 4

Thread: Delete Multiple cols in Excel VBA

  1. #1

    Smile Delete Multiple cols in Excel VBA

    How can i perform delete multiple cols in Excel using VBA.
    My approach is like this:

    [VBA] Workbooks.OpenText Filename:="C:\Users\karthic.rangaraj\Desktop\4412_CARQUEF.csv"

    ' Parse it using comma and semicolon as delimiters
    Range(Range("A1"), Range("A1").End(xlDown)).TextToColumns _
    DataType:=xlDelimited, _
    TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
    Semicolon:=True, Comma:=True, Space:=False, Other:=False, _
    FieldInfo:= _
    Array(Array(1, 2), Array(2, 2), Array(3, 2), Array(4, 1), Array(5, 2))

    ' Delete columns of ComputerSerial & UserName

    Columns("B:B").Select
    Selection.Delete Shift:=xlToLeft

    Columns("C:C").Select
    Selection.Delete Shift:=xlToLeft[/VBA]

    "Computer Name","Computer Serial","User name","Employee Number","Software name" --> this is the first line in the csv file & then i use the above code. It does exactly to remove the quotations, comma etc..but when i want to delete the "Computer Serial","User name" at the same it's not working.
    How can i delete B & C cols at the same time??? How can i create a executable macro in my Excel.

    Thanks guys!!

  2. #2
    Range("B:B,C:C").Delete - used this one & it works now.

    Still i need information to create a executable macro???

  3. #3
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    I have no idea what you mean, you simply put that in your macro somewhere or as a macro you call like this[VBA]Sub MyMacro()
    'my code here
    'mor of mycode
    Call DelCols
    'more of my code
    'more again
    End sub


    Sub DelCols()
    Range("D:E,G:H,J:K,M:N").EntireColumn.Delete
    End Sub[/VBA]
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  4. #4
    Thanks. Could u please tell me, how can i look for a text in a cell if there is a match then paste in the next cell.


    Mise Ã* jour de sécurité pour Windows XP (KB970430)
    Mise Ã* jour pour Windows XP (KB908531)
    Correctif pour Windows XP (KB961118)
    Mise Ã* jour de sécurité pour Windows XP (KB956744)
    Avenue Single User
    IBM iSeries Access for Windows
    E3 Graphics Base
    Désinstallation du logiciel d''imprimante IBM
    IBM Software Delivery Center Client and Agent
    Correctif Windows XP - KB867282
    Correctif Windows XP - KB873333
    I want to look for windows xp if it's matches then paste in the next cell, like that i want to check for IBM, Dell, Adobe, VLC etc.. Thanks for your support.

Posting Permissions

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