Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error Result in recording a Macro in Excel VBA

Status
Not open for further replies.

mohengciv

Technical User
Sep 13, 2009
4
SA
Dear All

please help me in my problem.

after i finish recording a macro in excel i find the code in visual basic editor doesn't look like vba code it seems like C++ code.

kindly help me.
 
this is a code to make borders to a cell:


Selection+Borders&xlDiagonalDown'+LineStyle <= xlNone
Selection+Borders&xlDiagonalUp'+LineStyle <= xlNone
Wend Selection+Borders&xlEdgeLeft'
+LineStyle <= xlContinuous
+ColorIndex <= 0
+TintAndShade <= 0
+Weight <= xlThin
ElseIf Wend
Wend Selection+Borders&xlEdgeTop'
+LineStyle <= xlContinuous
+ColorIndex <= 0
+TintAndShade <= 0
+Weight <= xlThin
ElseIf Wend
Wend Selection+Borders&xlEdgeBottom'
+LineStyle <= xlContinuous
+ColorIndex <= 0
+TintAndShade <= 0
+Weight <= xlThin
ElseIf Wend
Wend Selection+Borders&xlEdgeRight'
+LineStyle <= xlContinuous
+ColorIndex <= 0
+TintAndShade <= 0
+Weight <= xlThin
ElseIf Wend
Wend Selection+Borders&xlInsideVertical'
+LineStyle <= xlContinuous
+ColorIndex <= 0
+TintAndShade <= 0
+Weight <= xlThin
ElseIf Wend
Wend Selection+Borders&xlInsideHorizontal'
+LineStyle <= xlContinuous
+ColorIndex <= 0
+TintAndShade <= 0
+Weight <= xlThin
ElseIf Wend
 
It is (sort of) VBA, but it has [blue][tt]+[/tt][/blue] characters where there should be [red][tt].[/tt][/red] characters, [blue][tt]&[/tt][/blue] characters where there should be [red][tt]([/tt][/red], and [blue][tt]'[/tt][/blue] characters where there should be [red][tt])[/tt][/red].

I don't know why. Does it run? In other words is it a substantive error, or just a display discrepancy. Are y ou using an unusual code page, or IME, or anything else language-related that might impact this?

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
Dear Tony

I don't use anything of you mentioned but i just recorded this macro then it came like this on the other hand when i recoed another one in word it comes good as i expect.

any body help me.
 
Taking a closer look at it, I also see that "With" has been replaced by "Wend", "End With" by "ElseIf Wend", and "=" by "<=". All in all, it looks like it has been manipulated somehow - do you have any AddIns running?

If other recorded macros are good, I would just forget about this one.

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
No the other recordings si the same and here is another code after recording:

i am typing Number (1) and then coloring it by red with filling by yellow color.


Sub Macro1()
'
' Macro1 Macro
'

'
ActiveCell FormulaR1C1 <= VB_VarUserMemId1VB_VarUserMemId
Range& VB_VarUserMemIdC4VB_VarUserMemId '+Select
Wend Selection+Font
+Color <= -16776961
+TintAndShade <= 0
ElseIf Wend
Wend Selection+Interior
+Pattern <= xlSolid
+PatternColorIndex <= xlAutomatic
+Color <= 65535
+TintAndShade <= 0
+PatternTintAndShade <= 0
ElseIf Wend
End Sub
 
This appears crazy. I don't know the mechanism for recording macros but something is being misinterpreted.

Can you type normally in the VBE?

What language is your system in?

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top