Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2008

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tim New - 29 Jan 2008 01:51 GMT
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!
carlo - 29 Jan 2008 02:03 GMT
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

> 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
[quoted text clipped - 10 lines]
>
> *** Sent via Developersdexhttp://www.developersdex.com***
Tim New - 29 Jan 2008 02:23 GMT
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
Tim New - 29 Jan 2008 02:40 GMT
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
carlo - 29 Jan 2008 02:41 GMT
> Carlo,
> When I run it, I get a error at Next cell saying: Next without For.
[quoted text clipped - 13 lines]
>
> *** 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
Tim New - 29 Jan 2008 03:04 GMT
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
carlo - 29 Jan 2008 04:11 GMT
> Carlo,
> That worked!  I dont care what everyone else says, you're the best.  You
[quoted text clipped - 3 lines]
>
> *** 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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.