Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 21st, 2006, 08:37 AM
Registered User
 
Join Date: Sep 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default string manipulation problem

Hi
I have a strange problem with an Excel Macro. Part of the code should recognise if a text string begins with "The ", and if it does, moves "The " from the beginning to the end of the string.

If Left(Cells(i, 3), 4) = "The " Then
Cells(i, 3).Value = Cells(i, 3) & " The"
Cells(i, 3) = Right(Cells(i, 3), Len(Cells(i, 3)) - 4)
End If

Now when I step through the macro using F8, it recognises the string, and moves it to the end. But when I run the macro as a whole it seems to ignore the strings it should be altering!

Can anyone help me with this please?

Jamie
 
Old September 21st, 2006, 09:01 AM
Registered User
 
Join Date: Sep 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have found a work around. The For...Next loop I was using had a second part that created a sheet using the contents of the cell mentioned earlier. If I separate this into two discrete For....Next loops to achieve each task then my code works.

This doesn't explain why it didn't work before, but at least it works ok now!






Similar Threads
Thread Thread Starter Forum Replies Last Post
String manipulation Franco1 Visual Basic 2005 Basics 1 July 16th, 2008 12:53 PM
String manipulation pcase XSLT 5 June 14th, 2007 10:32 AM
String manipulation YoungLuke C# 4 May 4th, 2007 01:46 AM
String Manipulation twsinc Access 3 February 23rd, 2004 09:57 AM
String Manipulation Ben Access VBA 2 July 8th, 2003 05:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.