Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Macro to update excel cell.

Hi All,

I have a situation here. With a macro I am able to update the cell of a test spreadsheet (.xlsx).

But the same macro fails to update the original data sheet(.xlsm) I should need to update.

Am sorry that I can't share the original spreadsheet here.

What might be the reasons that blocking the update.?? Please help.

Below is the macro.

function a

 

    set objExcel = CreateObject("Excel.application")

 

    objExcel.DisplayAlerts = False

    set objWB = objExcel.Workbooks.Open("path\spreadhsheet.xlsx")

  

  With objWB.Worksheets(1)

        .Activate

        .Cells(1,1).Value = "12/25/2016"

    End With

    objWB.save

    objWB.close

    set objSheet = Nothing

    set objWB = Nothing

    set objExcel = Nothing

end function

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Thank you so much Karthik for your time and advice. Finally got the issue.

Here am using With objWB.Worksheets(1).


Maybe in the original spreadsheet, the order of the sheets is changed and the sheet am trying is not sheet1 may be.

When I tried giving the name  With objWB.Worksheets("******"). It worked fine.

View solution in original post

4 Replies
karthiksrqv
Partner - Creator II
Partner - Creator II

Hi Shiva,

Do you think it has something to do with folder privileges? Do you have read/write access to the folder in which the original xlsm is present?

Anonymous
Not applicable
Author

Yes Karthik, Actually both test and  original files are present in same folder.

karthiksrqv
Partner - Creator II
Partner - Creator II

Ok. A couple of things you could verify:

1. Is the xlsm password-protected?

2. You could try to see if you at all able to update a xlsm file (a second file that is of the xlsm type)

Anonymous
Not applicable
Author

Thank you so much Karthik for your time and advice. Finally got the issue.

Here am using With objWB.Worksheets(1).


Maybe in the original spreadsheet, the order of the sheets is changed and the sheet am trying is not sheet1 may be.

When I tried giving the name  With objWB.Worksheets("******"). It worked fine.