Syntax / Compile error

applebyd

Active Member
Joined
May 27, 2002
Messages
348
Hi all,

Havethe following which works fine as a formula in the workbook:

Range("AD2") = "=DATEVALUE(TRIM(MID(AE2,FIND(" ",AE2),3))&" "&LEFT(AE2,FIND(" ",AE2)-1)&" "&TRIM(MID(AE2,FIND(" ",AE2,FIND(" ",AE2)+1),5)))"

However, if I try and use it in VBA I am getting a syntax error (expected End of Statement) highlighted in the section ,AE2),3))&".

Not sure what is happening as if I put it in the workbook I can copy down quite happily. Just not when trying to do it programmatically.

My head hurts :-)

Any help appreciated.

Thanks

DaveA
 
Last edited:
Ok, it works perfectly and does away with the cumbersome Final_Tidy Sub.

Now tell me why!

Many many thanks

Regards
 
Upvote 0

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
DaveA

When you use things like Select/Selection in code you can't always be sure what ranges/sheets etc are being referred to.

In the code I posted the range references are explicit so, in theory anyway, the code should be applied to the correct ranges.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top