Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Not applicable

How to delete rows in exported excel using macro?

I have written a macro to export tables to a single sheet and it works fine. But I want to delete few specific rows and cells in the exported excel. How do I define it in a macro staticly?

2 Replies
vardhancse
Valued Contributor III

Re: How to delete rows in exported excel using macro?

what ever fields are not required can be de selected and can run the macro...

Highlighted
Luminary
Luminary

Re: How to delete rows in exported excel using macro?

I know this is an old thread but for me it was as simple as using

XLSheet1.Columns("A:E").Delete

in my macro VBA in Qlikview to remove those columns

eg - extracting a table to excel, formatting and removing some columns

 

sub test1  

    SET XLApp = CreateObject("Excel.Application")

    XLApp.Visible = true

 

   SET XLDoc = XLApp.Workbooks.Add

 

   SET XLSheet1 = XLDoc.Worksheets(1)

 

 

'Table export

 

   ActiveDocument.GetSheetObject("CH77").CopyTableToClipboard (true)

 

   XLSheet1.Paste XLSheet1.Range("A1")

       

   XLSheet1.Name = "E200 - Salary"

   

   

'AutoFit All Columns on Worksheet

 

   

   XLSheet1.Columns("H:H").ColumnWidth = 80

   XLSheet1.Columns("G:G").ColumnWidth = 80

   XLSheet1.Columns("A:E").Delete

   XLSheet1.Range("E1").Activate

   XLSheet1.Range("A1").Select

   

   XLSheet1.Cells.Select

   XLSheet1.Cells.EntireColumn.AutoFit

   XLSheet1.Cells.EntireRow.AutoFit

   XLSheet1.Columns("E:E").Select

   XLSheet1.Columns("E:E").Style = "Comma"

   XLSheet1.Range("A1").Select

   

end sub