PC Review


Reply
Thread Tools Rate Thread

creating a macro to add text to existing data already in cell

 
 
Tim New
Guest
Posts: n/a
 
      29th Jan 2008


Forgive me, I am new at Excel macros. I have a spreadsheet with
thousands of cells that now require extra text be added to the existing
data already in the cell. The extra text is the same for all cells
involved. I tried creating my own macro using record, doing the steps,
and stop recording but it applies the action to the original cells
rather than any new cells. I want to add "<br>Steel (Zinc Plated)" to
each cell.

Here is what I have so far:
ActiveCell.FormulaR1C1 = "<br>Steel (Zinc Plated)"

Thanks for the help!

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
carlo
Guest
Posts: n/a
 
      29th Jan 2008
Hi Tim

take this sub and change it for your purpose:

Sub abb_bla()

Dim cell As Range

For Each cell In UsedRange
cell.Value = cell.Value & "<br>Steel (Zinc Plated)"
Next cell

End Sub

hope that helps

Carlo


On Jan 29, 10:51*am, Tim New <tim...@hydrakinetics.com> wrote:
> Forgive me, I am new at Excel macros. *I have a spreadsheet with
> thousands of cells that now require extra text be added to the existing
> data already in the cell. *The extra text is the same for all cells
> involved. *I tried creating my own macro using record, doing the steps,
> and stop recording but it applies the action to the original cells
> rather than any new cells. *I want to add "<br>Steel (Zinc Plated)" to
> each cell.
>
> Here is what I have so far:
> ActiveCell.FormulaR1C1 = "<br>Steel (Zinc Plated)"
>
> Thanks for the help!
>
> *** Sent via Developersdexhttp://www.developersdex.com***


 
Reply With Quote
 
Tim New
Guest
Posts: n/a
 
      29th Jan 2008

Carlo,
When I run it, I get a error at Next cell saying: Next without For.
Here is what I now have:
Sub Macro8()
'
' Macro8 Macro
' Macro recorded 1/28/2008 by Timothy
'
' Keyboard Shortcut: Ctrl+e
'
ActiveCell.FormulaR1C1 = cell.Value & "<br>Steel Fitting (Zinc
Plated)"
Next cell

End Sub





*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
Tim New
Guest
Posts: n/a
 
      29th Jan 2008
I change the macro to:
Sub Macro8()
'
' Macro8 Macro
' Macro recorded 1/28/2008 by Timothy
'
' Keyboard Shortcut: Ctrl+e
'
Dim cell As Range

For Each cell In UsedRange
cell.Value = cell.Value & "<br>Steel (Zinc Plated)"
Next cell

End Sub

I now get runtime error 424 Object Required

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
carlo
Guest
Posts: n/a
 
      29th Jan 2008
On Jan 29, 11:23*am, Tim New <tim...@hydrakinetics.com> wrote:
> Carlo,
> When I run it, I get a error at Next cell saying: Next without For.
> Here is what I now have:
> Sub Macro8()
> '
> ' Macro8 Macro
> ' Macro recorded 1/28/2008 by Timothy
> '
> ' Keyboard Shortcut: Ctrl+e
> '
> * * ActiveCell.FormulaR1C1 = cell.Value & "<br>Steel Fitting (Zinc
> Plated)"
> * * Next cell
>
> End Sub
>
> *** Sent via Developersdexhttp://www.developersdex.com***


Hey Tim

well you don't have a For, that's what it says. try this:


Sub Macro8()
dim cell as range

for each cell in selection
cell.FormulaR1C1 = cell.Value & "<br>Steel Fitting (Zinc Plated)"
Next cell

End Sub

hope that helps
Carlo


 
Reply With Quote
 
Tim New
Guest
Posts: n/a
 
      29th Jan 2008
Carlo,
That worked! I dont care what everyone else says, you're the best. You
saved me tons of time and gave me a learning experience.
Thanks!
Timothy



*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
carlo
Guest
Posts: n/a
 
      29th Jan 2008
On Jan 29, 12:04*pm, Tim New <tim...@hydrakinetics.com> wrote:
> Carlo,
> That worked! *I dont care what everyone else says, you're the best. *You
> saved me tons of time and gave me a learning experience.
> Thanks!
> Timothy
>
> *** Sent via Developersdexhttp://www.developersdex.com***


What exactly do you mean with: "what everyone else says"?

glad that it worked, thanks for your feedback

Carlo
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003 Macro to add text to front of data in cell Rocky Lane Microsoft Excel Programming 30 28th Sep 2008 01:57 PM
Creating a graph with existing data...clear data after save =?Utf-8?B?Q2FtIE5lZXNvbg==?= Microsoft Excel Programming 3 15th Jun 2006 06:37 PM
Re: How do I Remove bullets from text data in Excel cell with macro? David McRitchie Microsoft Excel Programming 0 19th Sep 2004 09:22 PM
VBA Creating a Macro to Move some of the text from one cell to another Lowell B. Copeland Microsoft Excel Programming 4 28th Aug 2003 08:15 PM
Re: VBA Creating a Macro to Move some of the text from one cell to another Ron de Bruin Microsoft Excel Programming 0 28th Aug 2003 07:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:00 PM.