Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro for replacing current data in excel

Hi,

I'm new to Qlik/macros, any help is appreciated.

I'm looking to export my tables from Qlikview and paste into already created excel files where the current table will be overwritten with the new table.

Thanks,

3 Replies
MK9885
Master II
Master II

Maybe below link?

Qlikview to excel export macro

Of course you need to edit it as per your requirement, CH number or destination folder etc...

el_aprendiz111
Specialist
Specialist

Hi,

1 Example:

Sub DeleteFiles
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FileExists("C:\Folder\tmp.xlsx") then
filesys.DeleteFile "C:\Folder\tmp.xlsx"
Msgbox("Files Deleted")
Else
Msgbox("No Files to delete")
End If
End Sub


sub Export_Excel
set oXL=CreateObject("Excel.Application")

oXL.Workbooks.Add
oXL.visible=True
aSheetObj=Array("CH08","CH09")
for i=0 to UBound(aSheetObj)
oXL.Sheets.Add 
Set oSH = oXL.ActiveSheet
oSH.Range("A1").Select  
Set obj = ActiveDocument.GetSheetObject(aSheetObj(i))
obj.CopyTableToClipboard True
oSH.Paste
sCaption=obj.GetCaption.Name.v
set obj=Nothing

oSH.Name=left(sCaption,30)   
oSH.Rows("1:1").Select
oXL.Selection.Font.Bold = True     
oSH.Cells.Select
oXL.Selection.Columns.AutoFit
oSH.Range("A1").Select   

next
call DeleteFiles
oSH.SaveAs "C:\Folder\tmp.xlsx",51

set oSH=Nothing
set oXL=Nothing
end sub

joseduque
Partner - Contributor III
Partner - Contributor III

Hi,

So you need to updated it like a report? Where You have already an excel with data but you need to update just the graphic? Cause I recommend you to make the report from Qlikview:

You can Create your sheet with all the data and graphics you need, and update every month

Hope This helps