• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA Delete Columns

davidlim

Member
hi guys,


am wondering for a way to remove certain columns from a large excel table.


for example, i'm trying to remove Column AG, and Columns AA:AD.


I tried the below vba, it doesnt work (getting "Type Mismatch" message)


Sub Delete()

Columns("AG, AA:AD").Delete

End Sub


any ideas?


thanks!
 
Hi !


Avoid to call a Sub Delete 'cause it's a reserved word …

[pre]
Code:
Sub DelCol
Union(Columns("AA:AD"), Columns("AG")).Delete
end Sub
[/pre]
 
Sub DelCol

sheet1.activate

Union(Columns("AA:AD"), Columns("AG")).Delete

end Sub


now use the above code for sheet1.....


Regards

CA Mahaveer Somani
 
@mahaveer,


i encountered an issue with the vba.


if i use it on a new sheet with few rows, it works.


i tried to use it on large excel sheet (700K+ rows), i will get Error 400.


any idea/solution?


thanks!
 
Hi, davidlim!


Does this helps?

http://www.add-ins.com/support/microsoft-visual-basis-error-400.htm

http://www.mrexcel.com/forum/excel-questions/1721-visual-basic-error-400-a.html


Regards!
 
Back
Top