Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Select-method not working in macro

Hi everybody,

I have a problem again. On Friday I prepare a macro where I open an exsisted excel file, drop a table on a sheet and close the file while saving with another name. It has worked.

Than I reload the script on saturday, but nothing is happend Now the script shows me the error "select-method of the range-object could not be implenemt".

Makro.png

If I worte for the range cell, could the object not be suported. What's wrong with the code?

Regards Vicky

19 Replies
Not applicable
Author

The excel-file has one sheet with expressions and a diagramm, with fetch the data from the sheet Datenblatt. There are also four sheets with different pivot tables. And the sixth sheet is the sheet "Datenblatt" with no merged cells, or images, or expression. Only the table CH09 with former data is on it.

If it helps, you can rewrite the code so that it workes.

Not applicable
Author

weird stuff

but

if i select multiply sheets (right mouse button + Ctrl)  and save the excell - macro failed like you report:)

did you check this?

Not applicable
Author

check this file

(do not open it - just save to K catalog)

Not applicable
Author

No, I haven't got selected more than one sheet. But I haven't got selected the sheet "Datenblatt".

If I do that, the macro works fine. That's worst

Because I don't want start on the sheet "Datenblatt", if I open the excel file. I also can't guarantee, that my colleagues remember that they have to leave the excel file on this sheet, which they don't interessted. 

Can I say the Excel file something like, if time is < 06:00, then open with sheet "Datenblatt", otherwise with "Überblick"?

Not applicable
Author

as i see you can add one extra line

Set objCurrentSheet = objExcelDoc.Sheets("Datenblatt")

objExcelDoc.Sheets("Datenblatt").Select

objExcelDoc.Sheets("Datenblatt").Range("A1").Select

this should help you

Not applicable
Author

BTW what is this object for ... objCurrentSheet ?

Not applicable
Author

*head meets desk*

I though the line Set objCurrentSheet = objExcelDoc.Sheets("Datenblatt") was the selecting. I should find the time to learn intensiv more VB-Scripting.

Thank you very much

Not applicable
Author

hmm... the objCurrentSheet is perhaps a remnant of my attempts.

Not applicable
Author

i'm poor VB programist to but still wonder why line:

objExcelDoc.Sheets("Datenblatt").Range("A1").Select

doesn't activate the sheet 😕

Not applicable
Author

I also haven't much knowledge in VB. But I'm happy, that it works now