PDA

View Full Version : Clear the data



rider@1234
09-07-2019, 06:00 AM
My file is located in C:\Users\pc\Desktop
my file name is demo.xlsx
macro will be added in a different file excluding demo.xlsx
file is not opened so open the file by vba clear all the data in column A and Column B and save the file and close it

大灰狼1976
09-07-2019, 06:28 AM
Hi rider!

Sub test()
Dim pth$
pth = "C:\Users\pc\Desktop\demo.xlsx"
Application.ScreenUpdating = False
Workbooks.Open pth
ActiveSheet.Range("a:b") = ""
ActiveWorkbook.Close True
Application.ScreenUpdating = True
End Sub

rider@1234
09-07-2019, 07:24 AM
I think this code contains error it is not working
i am not getting error but after runing the macro it is processing but 5min have been passed but still it is unable to process
my data is not big i think code has an error plz have a relook Sir

mohadin
09-08-2019, 11:21 AM
Sub Doit()
Workbooks.Open Filename:="C:\Users\pc\Desktop\demo.xlsx"
Set wb = ActiveWorkbook
[a:b].ClearContents
wb.Save
wb.Close
End Sub