Rules
Terms of Use

Topic Options
#486578 - Fri Jul 24 2009 09:39 PM Macro's
jamlynncd Offline
Participant

Registered: Mon May 11 2009
Posts: 17
Loc: Panama City Florida USA      
I am using ms office 2007 and I'm having a problem recording macro's in excel.

I have several names with a number in front of each one:
1. Tom
2. Dick
3. Susan
4. Harry
5. Barbara
6. Henry
7. Gerald

What I want to do is create a macro to delete the number and period as well as any spaces up till the names. When I record the macro I do these steps in order.

1- F2
2- Home Key
3- delete key about 3 to 5 times
4- Then hit enter to shut recorder off

My problem is whenever I run the macro, it does those steps but changes all names to the name I recorded the macro. In other words those names above, I record the macro with tom being the cell recorded. After I run the macro I have 7 people named Tom. Any help will be most helpful.

Top
#486579 - Sat Jul 25 2009 03:55 AM Re: Macro's
sue943 Offline
Administrator

Registered: Sun Dec 19 1999
Posts: 38005
Loc: Jersey
Channel Islands    
That makes sense to me, the name Tom is part of your macro.

Have you managed to do this type of thing in the past and just 2007 causing a problem or is this just something that you are trying for the first time?
_________________________
Many a child has been spoiled because you can't spank a Grandma!

Top
#486580 - Sat Jul 25 2009 04:33 AM Re: Macro's
jamlynncd Offline
Participant

Registered: Mon May 11 2009
Posts: 17
Loc: Panama City Florida USA      
This is something new.

I hit the enter key as if I do not the stop recording macro is greyed out. How do I stop recording otherwise?

Top
#486581 - Sat Jul 25 2009 09:11 AM Re: Macro's
flopsymopsy Online   content

Administrator

Registered: Sat May 17 2008
Posts: 5470
Loc: Northampton England UK
In Excel 2007 to stop recording you have to click "stop recording" in the developers' tab.

I suspect you may need to use the Visual Basic Editor to include a range that will cover the options you need - perhaps someone else can help you with the VB code.

All I know is that Excel 2007 is a real pain - why they had to change things that worked perfectly well in previous versions is beyond me. It wasn't broken, there was no need to fix it.
_________________________
The Hubble Telescope has just picked up a sound from a fraction of a second before the Big Bang. The sound was "Uh oh".

Top
#486582 - Tue Jul 28 2009 07:29 AM Re: Macro's
PDAZ Offline
Mainstay

Registered: Sat Aug 02 2008
Posts: 505
Loc: Arizona USA
You can't accomplish that with a recorded macro -- you'll need VB to make it loop. Do you definitely need a macro or will text-to-columns work? That's the easiest method.

I haven't messed with Excel 2007 much -- I'm not sure if a macro I write in 2003 will run there, but I'll give it a try if I have some spare time at work today.

Top
#486583 - Wed Jul 29 2009 11:40 PM Re: Macro's
PDAZ Offline
Mainstay

Registered: Sat Aug 02 2008
Posts: 505
Loc: Arizona USA
Not sure if you still need a macro, but this might do what you needed. I tested it in Excel 2007 -- I'm with Flopsy -- no idea why they changed Excel!

Sub Shorten()

Shorten Macro
Removes beginning text in cell


Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
For Each cell In Range("A1:A" & Lastrow)
cell.Value = Trim(Mid(cell.Value, InStr(cell.Value, " ")))
Next

End Sub

Top

Moderator:  flopsymopsy, ladymacb29