SOLVED

Macro gives compile error

Copper Contributor

Dear friends,

 

I am new to Excel Macro. I recorded a very simple macro (typed 'a' in cell A1) and saved it for testing. When I run the macro, it gives me a compile error. I suppose there is something wrong with my settings. The image is attached below.

Please help me out. 

patilosophy_0-1617214170826.png

 

9 Replies

@patilosophy 

Weird! Try changing the macro to

 

Sub Macro1()
    Range("A1").Value = "a"
End Sub
Dear Hans,

Your code is working well. But why is my macro not being recorded correctly? I searched for a solution everywhere but this problem seems unique to me.

Please check this short video where I recorded my macro.
https://youtu.be/clYd5nc2fN0

Thanks,
Pratik

@patilosophy 

As I wrote in my first reply, it's weird. The macro recorder is far from perfect, but I haven't seen it mess up completely like this. It's clearly not your fault!

@Hans Vogelaar How do I correct this? Is there a reset option in Excel? 

I got a research paper pending due to this. Any solutions helps!

 

Regards

@patilosophy 

You might try recording another macro to see if the same problem (or a similar one) occurs. If so, you'll have to write your macros from scratch...

Not a single macro that I recorded is working. Guess I'll have to take the hard way of writing the code which I am clueless about. Is there a customer complaint mail id where I would get a response from MS?

@patilosophy 

You can click File > Feedback > Send a Frown, but you won't get a reply...

best response confirmed by patilosophy (Copper Contributor)
Solution
It looks like someone else had this issue and was able to fix it by uninstalling/reinstalling office. That would be the only thing I could suggest as you're certainly not doing anything wrong.

https://techcommunity.microsoft.com/t5/excel/excel-macro-recording-generate-wrong-vba/m-p/190857
This was the last option but it worked. Thanks!
1 best response

Accepted Solutions
best response confirmed by patilosophy (Copper Contributor)
Solution
It looks like someone else had this issue and was able to fix it by uninstalling/reinstalling office. That would be the only thing I could suggest as you're certainly not doing anything wrong.

https://techcommunity.microsoft.com/t5/excel/excel-macro-recording-generate-wrong-vba/m-p/190857

View solution in original post