Hi guys,
this is the code that VBA created when I recorded a simple macro to make a cell yellowish.
a syntax error window pop up this is the code generated,
anyone knows why
Sub Macro2()
'
' Macro2 Macro
'
'
Wend Selection+Interior
+Pattern <= xlSolid
+PatternColorIndex <= xlAutomatic
+Color <= 65535
+TintAndShade <= 0
+PatternTintAndShade <= 0
ElseIf Wend
End Sub
First - please read the forum rules - all code must be wrapped in CODE tags.
I have NO idea how the Macro recorder generated the above code - it should be
Try recording it again - Wend is part a loop control structure and there is an End If so there should be a starting IF (conditional statement) - so I have no idea why the recorder did this?? Did you copy and paste the recorded macro into another macro??sub macro2() With Selection.Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .Color = 65535 .TintAndShade = 0 .PatternTintAndShade = 0 End With End Sub
Hope this helps.
Anthony
“Confidence never comes from having all the answers; it comes from being open to all the questions.”
PS: Remember to mark your questions as Solved once you are satisfied and rate the answer(s) questions.”
Last edited by smuzoen; 01-26-2012 at 08:28 PM.
As per forum rules can you wrap your code in cod tags.
As for you problem , what exactly are you trying to achieve? If you could post a sample workbook to better describe what you are after, that would help a lot.
If you are happy with the answer, please click the Star icon in the below left hand corner.
Good sites to start learning.
snb's VBA Help Files
Jerry Beaucaires Excel Assistant
J & R Excel Consultancy Services
How to post code correctly: Correct Code Posting
@smuzoen : I typed the code you wrote me it worked.
The prosblem is why the recorder is recording like that. it seems to be a bug in the installation, and excel need to be reinstalled.
![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks