Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 28
Default Create a macro to eliminate certain words from several columns

Hello, me again, another question to elaborate further on my last
post/question. Is it possible to creat a program/macro that would eliminate
certain words from certain columns and leave the rest of the information
intact. For example:

A1 B1 C1
State: Florida Phone: 321-555-1234 Company: ABC Store
State: New Mexico Phone: 214-555-9876 Company: XYZ, LLC.
State: Georgia Phone: 305-555-4321 Company: Stuff, Inc.

I would like to get rid off the words "State", "Phone", and "Company" so my
columns would look like this:

A1 B1 C1
Florida 321-555-1234 ABC Store
New Mexico 214-555-9876 XYZ, LLC.
Georgia 305-555-4321 Stuff, Inc.

A macro would make things so much faster for me. Thanks again!!!

Jorge


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default Create a macro to eliminate certain words from several columns

Try this:

Sub cleanout()
s = Array("State: ", "Phone: ", "Company: ")
For I = 0 To 2
n = Cells(Rows.Count, I + 1).End(xlUp).Row
v = s(I)
For j = 1 To n
Set r = Cells(j, I + 1)
r.Value = Replace(r.Value, v, "", 1)
Next
Next
End Sub

--
Gary''s Student - gsnu200765


"Jorge" wrote:

Hello, me again, another question to elaborate further on my last
post/question. Is it possible to creat a program/macro that would eliminate
certain words from certain columns and leave the rest of the information
intact. For example:

A1 B1 C1
State: Florida Phone: 321-555-1234 Company: ABC Store
State: New Mexico Phone: 214-555-9876 Company: XYZ, LLC.
State: Georgia Phone: 305-555-4321 Company: Stuff, Inc.

I would like to get rid off the words "State", "Phone", and "Company" so my
columns would look like this:

A1 B1 C1
Florida 321-555-1234 ABC Store
New Mexico 214-555-9876 XYZ, LLC.
Georgia 305-555-4321 Stuff, Inc.

A macro would make things so much faster for me. Thanks again!!!

Jorge


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default Create a macro to eliminate certain words from several columns

Record a macro when you do a bunch of edit|replaces.


Jorge wrote:

Hello, me again, another question to elaborate further on my last
post/question. Is it possible to creat a program/macro that would eliminate
certain words from certain columns and leave the rest of the information
intact. For example:

A1 B1 C1
State: Florida Phone: 321-555-1234 Company: ABC Store
State: New Mexico Phone: 214-555-9876 Company: XYZ, LLC.
State: Georgia Phone: 305-555-4321 Company: Stuff, Inc.

I would like to get rid off the words "State", "Phone", and "Company" so my
columns would look like this:

A1 B1 C1
Florida 321-555-1234 ABC Store
New Mexico 214-555-9876 XYZ, LLC.
Georgia 305-555-4321 Stuff, Inc.

A macro would make things so much faster for me. Thanks again!!!

Jorge


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 38
Default Create a macro to eliminate certain words from several columns

If you're new to macros, you could try to use the recorder (Tools/
Macro/Record New Macro), use find and replace, and stop the recorder.

This would create a macro that you could run again in the future. It
also is a great way to learn how macros work because if you edit the
macro (Tools/Macro/Macros/Edit) you can see what the recorder has
collected. Note that recorded macros contain every option, even those
you did not select, so they get a little wordy sometimes.

On Jan 16, 1:22 pm, Jorge wrote:
Hello, me again, another question to elaborate further on my last
post/question. Is it possible to creat a program/macro that would eliminate
certain words from certain columns and leave the rest of the information
intact. For example:

A1 B1 C1
State: Florida Phone: 321-555-1234 Company: ABC Store
State: New Mexico Phone: 214-555-9876 Company: XYZ, LLC.
State: Georgia Phone: 305-555-4321 Company: Stuff, Inc.

I would like to get rid off the words "State", "Phone", and "Company" so my
columns would look like this:

A1 B1 C1
Florida 321-555-1234 ABC Store
New Mexico 214-555-9876 XYZ, LLC.
Georgia 305-555-4321 Stuff, Inc.

A macro would make things so much faster for me. Thanks again!!!

Jorge


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 28
Default Create a macro to eliminate certain words from several columns

Hello Gary,

Thank you for all your help. I got it to work for the "State" word but not
for the "Company" or "Phone". Any ideas? I am doing the same example with the
three columns A, B, and C with the words State only to be found in column A,
Phone in B and Company in C. Once I get this to work, I'll twick it so I can
include other words like "Email", "Agent", "City", etc...any advice for the
twicking portion of my problem is welcome since although I can more or less
follow the code (I took C++ like a zillion years ago and understand the
basics of coding) I am not certain on who it works.

Thanks, everyone in this forum has helped me tremedously!!!

Jorge

"Gary''s Student" wrote:

Try this:

Sub cleanout()
s = Array("State: ", "Phone: ", "Company: ")
For I = 0 To 2
n = Cells(Rows.Count, I + 1).End(xlUp).Row
v = s(I)
For j = 1 To n
Set r = Cells(j, I + 1)
r.Value = Replace(r.Value, v, "", 1)
Next
Next
End Sub

--
Gary''s Student - gsnu200765


"Jorge" wrote:

Hello, me again, another question to elaborate further on my last
post/question. Is it possible to creat a program/macro that would eliminate
certain words from certain columns and leave the rest of the information
intact. For example:

A1 B1 C1
State: Florida Phone: 321-555-1234 Company: ABC Store
State: New Mexico Phone: 214-555-9876 Company: XYZ, LLC.
State: Georgia Phone: 305-555-4321 Company: Stuff, Inc.

I would like to get rid off the words "State", "Phone", and "Company" so my
columns would look like this:

A1 B1 C1
Florida 321-555-1234 ABC Store
New Mexico 214-555-9876 XYZ, LLC.
Georgia 305-555-4321 Stuff, Inc.

A macro would make things so much faster for me. Thanks again!!!

Jorge


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Eliminate Duplicate Rows - Add columns Accordingly meendar Excel Discussion (Misc queries) 1 April 11th 06 05:15 PM
How do I create a macro that will compare columns and place data CompuCat Excel Worksheet Functions 0 March 20th 06 06:21 PM
How do I chage/eliminate the names of the columns and rows Diader Charts and Charting in Excel 1 January 23rd 06 04:52 PM
Eliminate unused columns jlbreyer Excel Discussion (Misc queries) 3 June 20th 05 07:16 PM
macro to eliminate spaces between words CSAM Excel Discussion (Misc queries) 3 December 17th 04 11:39 AM


All times are GMT +1. The time now is 11:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"