Can someone help with code to delete multiple columns from an excel
spreadsheet? I know which columns I need to delete. The code below will
delete a single column but I'm not sure how to delete multiple columns. I'm
tried experimenting with Dim rg As Excel.Range = xlSheet.Columns ("B, D, G,
K, L") but no joy. Thanks in advance
Dim xlApp As Excel.Applicati on
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
xlApp = CreateObject("E xcel.Applicatio n")
xlBook = xlApp.Workbooks .Open("D:\Augus t_Sales.xls")
xlSheet = xlBook.Workshee ts(1)
Dim rg As Excel.Range = xlSheet.Columns ("B")
rg.Select()
rg.Delete()
xlBook.Save()
xlApp.Quit()
System.Runtime. InteropServices .Marshal.Releas eComObject(xlBo ok)
System.Runtime. InteropServices .Marshal.Releas eComObject(xlAp p)
xlSheet = Nothing
xlBook = Nothing
xlApp = Nothing
spreadsheet? I know which columns I need to delete. The code below will
delete a single column but I'm not sure how to delete multiple columns. I'm
tried experimenting with Dim rg As Excel.Range = xlSheet.Columns ("B, D, G,
K, L") but no joy. Thanks in advance
Dim xlApp As Excel.Applicati on
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
xlApp = CreateObject("E xcel.Applicatio n")
xlBook = xlApp.Workbooks .Open("D:\Augus t_Sales.xls")
xlSheet = xlBook.Workshee ts(1)
Dim rg As Excel.Range = xlSheet.Columns ("B")
rg.Select()
rg.Delete()
xlBook.Save()
xlApp.Quit()
System.Runtime. InteropServices .Marshal.Releas eComObject(xlBo ok)
System.Runtime. InteropServices .Marshal.Releas eComObject(xlAp p)
xlSheet = Nothing
xlBook = Nothing
xlApp = Nothing
Comment