Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Filename Problem

I currently asked the below question and received the below equation along
with several other equations. It works great, however, it will not accomodate
for those employer names that do not have commas or the word "The". Can
anyone help in finding an equation that would accomodate for all three cases?

__________________________________________________ _______



=LEFT(A2,FIND(",",A2,1)-1)
will return all the text to the left of the comma
--
Gary's Student


"Help?" wrote:

I currently have a excel macro that pulls information from the excel columns
and adds it to the filename. Then, the macro will convert to csv file. A
column exists in the file called EMPLOYER NAME. An individual will insert a
company's name in this column. This will be pulled into the filename.
However, if a company is ABC Company, Inc. - the comma in the filename throws
our printing system into a loop. So, I use the equation =LEFT(A2,FIND("
",A2))&MID(A2,FIND(" ",A2)+1,0) to only pull in the first portion of the name
into another column and then insert the new name into the filename. Works
good, but I am now running into the problem of the name being The ABC
Company, Inc. The comma is not present, but the filename is The. Does anyone
know an equation I could use that would only pick out ABC Company and leave
The and the comma out?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Filename Problem

=SUBSTITUTE(LEFT(A2,FIND(",",A2,1)-1),"The ","")

This will remove the comma and everything to the right of the comma. It
will also remove
The
as coded it looks for a capital T and a trialing blank
--
Gary's Student


"Help?" wrote:

I currently asked the below question and received the below equation along
with several other equations. It works great, however, it will not accomodate
for those employer names that do not have commas or the word "The". Can
anyone help in finding an equation that would accomodate for all three cases?

__________________________________________________ _______



=LEFT(A2,FIND(",",A2,1)-1)
will return all the text to the left of the comma
--
Gary's Student


"Help?" wrote:

I currently have a excel macro that pulls information from the excel columns
and adds it to the filename. Then, the macro will convert to csv file. A
column exists in the file called EMPLOYER NAME. An individual will insert a
company's name in this column. This will be pulled into the filename.
However, if a company is ABC Company, Inc. - the comma in the filename throws
our printing system into a loop. So, I use the equation =LEFT(A2,FIND("
",A2))&MID(A2,FIND(" ",A2)+1,0) to only pull in the first portion of the name
into another column and then insert the new name into the filename. Works
good, but I am now running into the problem of the name being The ABC
Company, Inc. The comma is not present, but the filename is The. Does anyone
know an equation I could use that would only pick out ABC Company and leave
The and the comma out?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Filename Problem

Gary,
It's still not working for any of the cases like:
The Volunteer Inc.
Volunteer
Volunteer, Inc.
The Volunteer, Inc.

It's not acting like it wants to pull A2 into the other column when I use
the below equation.

"Gary''s Student" wrote:

=SUBSTITUTE(LEFT(A2,FIND(",",A2,1)-1),"The ","")

This will remove the comma and everything to the right of the comma. It
will also remove
The
as coded it looks for a capital T and a trialing blank
--
Gary's Student


"Help?" wrote:

I currently asked the below question and received the below equation along
with several other equations. It works great, however, it will not accomodate
for those employer names that do not have commas or the word "The". Can
anyone help in finding an equation that would accomodate for all three cases?

__________________________________________________ _______



=LEFT(A2,FIND(",",A2,1)-1)
will return all the text to the left of the comma
--
Gary's Student


"Help?" wrote:

I currently have a excel macro that pulls information from the excel columns
and adds it to the filename. Then, the macro will convert to csv file. A
column exists in the file called EMPLOYER NAME. An individual will insert a
company's name in this column. This will be pulled into the filename.
However, if a company is ABC Company, Inc. - the comma in the filename throws
our printing system into a loop. So, I use the equation =LEFT(A2,FIND("
",A2))&MID(A2,FIND(" ",A2)+1,0) to only pull in the first portion of the name
into another column and then insert the new name into the filename. Works
good, but I am now running into the problem of the name being The ABC
Company, Inc. The comma is not present, but the filename is The. Does anyone
know an equation I could use that would only pick out ABC Company and leave
The and the comma out?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,311
Default Filename Problem

Oh sure, you can use that very plain and simple formula...or you could use
this one.

=LEFT(IF(LEFT(A2,3)="The",RIGHT(A2,LEN(A2)-4),LEFT(A2,LEN(A2)-5)),FIND(",",IF(LEFT(A2,3)="The",RIGHT(A2,LEN(A2)-4),LEFT(A2,LEN(A2)-4)))-1)



"Gary''s Student" wrote in message
...
=SUBSTITUTE(LEFT(A2,FIND(",",A2,1)-1),"The ","")

This will remove the comma and everything to the right of the comma. It
will also remove
The
as coded it looks for a capital T and a trialing blank
--
Gary's Student


"Help?" wrote:

I currently asked the below question and received the below equation
along
with several other equations. It works great, however, it will not
accomodate
for those employer names that do not have commas or the word "The". Can
anyone help in finding an equation that would accomodate for all three
cases?

__________________________________________________ _______



=LEFT(A2,FIND(",",A2,1)-1)
will return all the text to the left of the comma
--
Gary's Student


"Help?" wrote:

I currently have a excel macro that pulls information from the excel
columns
and adds it to the filename. Then, the macro will convert to csv file.
A
column exists in the file called EMPLOYER NAME. An individual will
insert a
company's name in this column. This will be pulled into the filename.
However, if a company is ABC Company, Inc. - the comma in the filename
throws
our printing system into a loop. So, I use the equation =LEFT(A2,FIND("
",A2))&MID(A2,FIND(" ",A2)+1,0) to only pull in the first portion of
the name
into another column and then insert the new name into the filename.
Works
good, but I am now running into the problem of the name being The ABC
Company, Inc. The comma is not present, but the filename is The. Does
anyone
know an equation I could use that would only pick out ABC Company and
leave
The and the comma out?




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Filename Problem

It will not work for the last two cases you listed because they don't contain
commas.

=SUBSTITUTE(LEFT(A2,FIND(",",A2,1)-1),"The ","")

will remove the The and also everything to the right of a comma including
the comma.

Just make sure you version of Excel supports the SUBSTITUTE() function.
--
Gary's Student


"Help?" wrote:

Gary,
It's still not working for any of the cases like:
The Volunteer Inc.
Volunteer
Volunteer, Inc.
The Volunteer, Inc.

It's not acting like it wants to pull A2 into the other column when I use
the below equation.

"Gary''s Student" wrote:

=SUBSTITUTE(LEFT(A2,FIND(",",A2,1)-1),"The ","")

This will remove the comma and everything to the right of the comma. It
will also remove
The
as coded it looks for a capital T and a trialing blank
--
Gary's Student


"Help?" wrote:

I currently asked the below question and received the below equation along
with several other equations. It works great, however, it will not accomodate
for those employer names that do not have commas or the word "The". Can
anyone help in finding an equation that would accomodate for all three cases?

__________________________________________________ _______



=LEFT(A2,FIND(",",A2,1)-1)
will return all the text to the left of the comma
--
Gary's Student


"Help?" wrote:

I currently have a excel macro that pulls information from the excel columns
and adds it to the filename. Then, the macro will convert to csv file. A
column exists in the file called EMPLOYER NAME. An individual will insert a
company's name in this column. This will be pulled into the filename.
However, if a company is ABC Company, Inc. - the comma in the filename throws
our printing system into a loop. So, I use the equation =LEFT(A2,FIND("
",A2))&MID(A2,FIND(" ",A2)+1,0) to only pull in the first portion of the name
into another column and then insert the new name into the filename. Works
good, but I am now running into the problem of the name being The ABC
Company, Inc. The comma is not present, but the filename is The. Does anyone
know an equation I could use that would only pick out ABC Company and leave
The and the comma out?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Filename Problem

Is
=SUBSTITUTE(LEFT(A2,FIND(",",A2 & ",",1)-1),"The ","")
any better??
--
Gary's Student


"Help?" wrote:

Gary,
It's still not working for any of the cases like:
The Volunteer Inc.
Volunteer
Volunteer, Inc.
The Volunteer, Inc.

It's not acting like it wants to pull A2 into the other column when I use
the below equation.

"Gary''s Student" wrote:

=SUBSTITUTE(LEFT(A2,FIND(",",A2,1)-1),"The ","")

This will remove the comma and everything to the right of the comma. It
will also remove
The
as coded it looks for a capital T and a trialing blank
--
Gary's Student


"Help?" wrote:

I currently asked the below question and received the below equation along
with several other equations. It works great, however, it will not accomodate
for those employer names that do not have commas or the word "The". Can
anyone help in finding an equation that would accomodate for all three cases?

__________________________________________________ _______



=LEFT(A2,FIND(",",A2,1)-1)
will return all the text to the left of the comma
--
Gary's Student


"Help?" wrote:

I currently have a excel macro that pulls information from the excel columns
and adds it to the filename. Then, the macro will convert to csv file. A
column exists in the file called EMPLOYER NAME. An individual will insert a
company's name in this column. This will be pulled into the filename.
However, if a company is ABC Company, Inc. - the comma in the filename throws
our printing system into a loop. So, I use the equation =LEFT(A2,FIND("
",A2))&MID(A2,FIND(" ",A2)+1,0) to only pull in the first portion of the name
into another column and then insert the new name into the filename. Works
good, but I am now running into the problem of the name being The ABC
Company, Inc. The comma is not present, but the filename is The. Does anyone
know an equation I could use that would only pick out ABC Company and leave
The and the comma out?

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Filename Problem

What about a Replace macro that would be just for commas?

"PCLIVE" wrote:

Oh sure, you can use that very plain and simple formula...or you could use
this one.

=LEFT(IF(LEFT(A2,3)="The",RIGHT(A2,LEN(A2)-4),LEFT(A2,LEN(A2)-5)),FIND(",",IF(LEFT(A2,3)="The",RIGHT(A2,LEN(A2)-4),LEFT(A2,LEN(A2)-4)))-1)



"Gary''s Student" wrote in message
...
=SUBSTITUTE(LEFT(A2,FIND(",",A2,1)-1),"The ","")

This will remove the comma and everything to the right of the comma. It
will also remove
The
as coded it looks for a capital T and a trialing blank
--
Gary's Student


"Help?" wrote:

I currently asked the below question and received the below equation
along
with several other equations. It works great, however, it will not
accomodate
for those employer names that do not have commas or the word "The". Can
anyone help in finding an equation that would accomodate for all three
cases?

__________________________________________________ _______



=LEFT(A2,FIND(",",A2,1)-1)
will return all the text to the left of the comma
--
Gary's Student


"Help?" wrote:

I currently have a excel macro that pulls information from the excel
columns
and adds it to the filename. Then, the macro will convert to csv file.
A
column exists in the file called EMPLOYER NAME. An individual will
insert a
company's name in this column. This will be pulled into the filename.
However, if a company is ABC Company, Inc. - the comma in the filename
throws
our printing system into a loop. So, I use the equation =LEFT(A2,FIND("
",A2))&MID(A2,FIND(" ",A2)+1,0) to only pull in the first portion of
the name
into another column and then insert the new name into the filename.
Works
good, but I am now running into the problem of the name being The ABC
Company, Inc. The comma is not present, but the filename is The. Does
anyone
know an equation I could use that would only pick out ABC Company and
leave
The and the comma out?




  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Filename Problem

It would have to be for only cell AW2. Any suggestions? I am not familiar
with this aspect.

"Help?" wrote:

What about a Replace macro that would be just for commas?

"PCLIVE" wrote:

Oh sure, you can use that very plain and simple formula...or you could use
this one.

=LEFT(IF(LEFT(A2,3)="The",RIGHT(A2,LEN(A2)-4),LEFT(A2,LEN(A2)-5)),FIND(",",IF(LEFT(A2,3)="The",RIGHT(A2,LEN(A2)-4),LEFT(A2,LEN(A2)-4)))-1)



"Gary''s Student" wrote in message
...
=SUBSTITUTE(LEFT(A2,FIND(",",A2,1)-1),"The ","")

This will remove the comma and everything to the right of the comma. It
will also remove
The
as coded it looks for a capital T and a trialing blank
--
Gary's Student


"Help?" wrote:

I currently asked the below question and received the below equation
along
with several other equations. It works great, however, it will not
accomodate
for those employer names that do not have commas or the word "The". Can
anyone help in finding an equation that would accomodate for all three
cases?

__________________________________________________ _______



=LEFT(A2,FIND(",",A2,1)-1)
will return all the text to the left of the comma
--
Gary's Student


"Help?" wrote:

I currently have a excel macro that pulls information from the excel
columns
and adds it to the filename. Then, the macro will convert to csv file.
A
column exists in the file called EMPLOYER NAME. An individual will
insert a
company's name in this column. This will be pulled into the filename.
However, if a company is ABC Company, Inc. - the comma in the filename
throws
our printing system into a loop. So, I use the equation =LEFT(A2,FIND("
",A2))&MID(A2,FIND(" ",A2)+1,0) to only pull in the first portion of
the name
into another column and then insert the new name into the filename.
Works
good, but I am now running into the problem of the name being The ABC
Company, Inc. The comma is not present, but the filename is The. Does
anyone
know an equation I could use that would only pick out ABC Company and
leave
The and the comma out?




  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,311
Default Filename Problem

I think the last suggestion from Gary's Student was the best solution,
unless you're looking to only use the source cell and have your results in
that cell.
=SUBSTITUTE(LEFT(A2,FIND(",",A2 & ",",1)-1),"The ","")

"Help?" wrote in message
...
What about a Replace macro that would be just for commas?

"PCLIVE" wrote:

Oh sure, you can use that very plain and simple formula...or you could
use
this one.

=LEFT(IF(LEFT(A2,3)="The",RIGHT(A2,LEN(A2)-4),LEFT(A2,LEN(A2)-5)),FIND(",",IF(LEFT(A2,3)="The",RIGHT(A2,LEN(A2)-4),LEFT(A2,LEN(A2)-4)))-1)



"Gary''s Student" wrote in
message
...
=SUBSTITUTE(LEFT(A2,FIND(",",A2,1)-1),"The ","")

This will remove the comma and everything to the right of the comma.
It
will also remove
The
as coded it looks for a capital T and a trialing blank
--
Gary's Student


"Help?" wrote:

I currently asked the below question and received the below equation
along
with several other equations. It works great, however, it will not
accomodate
for those employer names that do not have commas or the word "The".
Can
anyone help in finding an equation that would accomodate for all three
cases?

__________________________________________________ _______



=LEFT(A2,FIND(",",A2,1)-1)
will return all the text to the left of the comma
--
Gary's Student


"Help?" wrote:

I currently have a excel macro that pulls information from the excel
columns
and adds it to the filename. Then, the macro will convert to csv
file.
A
column exists in the file called EMPLOYER NAME. An individual will
insert a
company's name in this column. This will be pulled into the
filename.
However, if a company is ABC Company, Inc. - the comma in the
filename
throws
our printing system into a loop. So, I use the equation
=LEFT(A2,FIND("
",A2))&MID(A2,FIND(" ",A2)+1,0) to only pull in the first portion of
the name
into another column and then insert the new name into the filename.
Works
good, but I am now running into the problem of the name being The
ABC
Company, Inc. The comma is not present, but the filename is The.
Does
anyone
know an equation I could use that would only pick out ABC Company
and
leave
The and the comma out?






  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Filename Problem

It didn't work either. Is their a macro that could replace just the comma in
cell AW2 with a simple space?

"PCLIVE" wrote:

I think the last suggestion from Gary's Student was the best solution,
unless you're looking to only use the source cell and have your results in
that cell.
=SUBSTITUTE(LEFT(A2,FIND(",",A2 & ",",1)-1),"The ","")

"Help?" wrote in message
...
What about a Replace macro that would be just for commas?

"PCLIVE" wrote:

Oh sure, you can use that very plain and simple formula...or you could
use
this one.

=LEFT(IF(LEFT(A2,3)="The",RIGHT(A2,LEN(A2)-4),LEFT(A2,LEN(A2)-5)),FIND(",",IF(LEFT(A2,3)="The",RIGHT(A2,LEN(A2)-4),LEFT(A2,LEN(A2)-4)))-1)



"Gary''s Student" wrote in
message
...
=SUBSTITUTE(LEFT(A2,FIND(",",A2,1)-1),"The ","")

This will remove the comma and everything to the right of the comma.
It
will also remove
The
as coded it looks for a capital T and a trialing blank
--
Gary's Student


"Help?" wrote:

I currently asked the below question and received the below equation
along
with several other equations. It works great, however, it will not
accomodate
for those employer names that do not have commas or the word "The".
Can
anyone help in finding an equation that would accomodate for all three
cases?

__________________________________________________ _______



=LEFT(A2,FIND(",",A2,1)-1)
will return all the text to the left of the comma
--
Gary's Student


"Help?" wrote:

I currently have a excel macro that pulls information from the excel
columns
and adds it to the filename. Then, the macro will convert to csv
file.
A
column exists in the file called EMPLOYER NAME. An individual will
insert a
company's name in this column. This will be pulled into the
filename.
However, if a company is ABC Company, Inc. - the comma in the
filename
throws
our printing system into a loop. So, I use the equation
=LEFT(A2,FIND("
",A2))&MID(A2,FIND(" ",A2)+1,0) to only pull in the first portion of
the name
into another column and then insert the new name into the filename.
Works
good, but I am now running into the problem of the name being The
ABC
Company, Inc. The comma is not present, but the filename is The.
Does
anyone
know an equation I could use that would only pick out ABC Company
and
leave
The and the comma out?









  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,311
Default Filename Problem

I'm sure someone here will be able to explain this as I am not sure why it
works. However, the code below appears to work if you want to remove
commas, If you want a space in place of a comma, just add a space between
the two quotes.


Sub RemoveCommas()

n = Range("AW2").Replace(",", "")

End Sub


Regards,
Paul

"Help?" wrote in message
...
It didn't work either. Is their a macro that could replace just the comma
in
cell AW2 with a simple space?

"PCLIVE" wrote:

I think the last suggestion from Gary's Student was the best solution,
unless you're looking to only use the source cell and have your results
in
that cell.
=SUBSTITUTE(LEFT(A2,FIND(",",A2 & ",",1)-1),"The ","")

"Help?" wrote in message
...
What about a Replace macro that would be just for commas?

"PCLIVE" wrote:

Oh sure, you can use that very plain and simple formula...or you could
use
this one.

=LEFT(IF(LEFT(A2,3)="The",RIGHT(A2,LEN(A2)-4),LEFT(A2,LEN(A2)-5)),FIND(",",IF(LEFT(A2,3)="The",RIGHT(A2,LEN(A2)-4),LEFT(A2,LEN(A2)-4)))-1)



"Gary''s Student" wrote in
message
...
=SUBSTITUTE(LEFT(A2,FIND(",",A2,1)-1),"The ","")

This will remove the comma and everything to the right of the comma.
It
will also remove
The
as coded it looks for a capital T and a trialing blank
--
Gary's Student


"Help?" wrote:

I currently asked the below question and received the below
equation
along
with several other equations. It works great, however, it will not
accomodate
for those employer names that do not have commas or the word "The".
Can
anyone help in finding an equation that would accomodate for all
three
cases?

__________________________________________________ _______



=LEFT(A2,FIND(",",A2,1)-1)
will return all the text to the left of the comma
--
Gary's Student


"Help?" wrote:

I currently have a excel macro that pulls information from the
excel
columns
and adds it to the filename. Then, the macro will convert to csv
file.
A
column exists in the file called EMPLOYER NAME. An individual
will
insert a
company's name in this column. This will be pulled into the
filename.
However, if a company is ABC Company, Inc. - the comma in the
filename
throws
our printing system into a loop. So, I use the equation
=LEFT(A2,FIND("
",A2))&MID(A2,FIND(" ",A2)+1,0) to only pull in the first portion
of
the name
into another column and then insert the new name into the
filename.
Works
good, but I am now running into the problem of the name being The
ABC
Company, Inc. The comma is not present, but the filename is The.
Does
anyone
know an equation I could use that would only pick out ABC Company
and
leave
The and the comma out?









  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Filename Problem

Hey guys:
This is still not working.

"PCLIVE" wrote:

Oh sure, you can use that very plain and simple formula...or you could use
this one.

=LEFT(IF(LEFT(A2,3)="The",RIGHT(A2,LEN(A2)-4),LEFT(A2,LEN(A2)-5)),FIND(",",IF(LEFT(A2,3)="The",RIGHT(A2,LEN(A2)-4),LEFT(A2,LEN(A2)-4)))-1)



"Gary''s Student" wrote in message
...
=SUBSTITUTE(LEFT(A2,FIND(",",A2,1)-1),"The ","")

This will remove the comma and everything to the right of the comma. It
will also remove
The
as coded it looks for a capital T and a trialing blank
--
Gary's Student


"Help?" wrote:

I currently asked the below question and received the below equation
along
with several other equations. It works great, however, it will not
accomodate
for those employer names that do not have commas or the word "The". Can
anyone help in finding an equation that would accomodate for all three
cases?

__________________________________________________ _______



=LEFT(A2,FIND(",",A2,1)-1)
will return all the text to the left of the comma
--
Gary's Student


"Help?" wrote:

I currently have a excel macro that pulls information from the excel
columns
and adds it to the filename. Then, the macro will convert to csv file.
A
column exists in the file called EMPLOYER NAME. An individual will
insert a
company's name in this column. This will be pulled into the filename.
However, if a company is ABC Company, Inc. - the comma in the filename
throws
our printing system into a loop. So, I use the equation =LEFT(A2,FIND("
",A2))&MID(A2,FIND(" ",A2)+1,0) to only pull in the first portion of
the name
into another column and then insert the new name into the filename.
Works
good, but I am now running into the problem of the name being The ABC
Company, Inc. The comma is not present, but the filename is The. Does
anyone
know an equation I could use that would only pick out ABC Company and
leave
The and the comma out?




  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Filename Problem

Sub one_last_try()
Dim r As Range
Set r = Range("AW2")
With r
.Value = WorksheetFunction.Substitute(.Value, ",", " ")
End With
End Sub
--
Gary's Student


"Help?" wrote:

It didn't work either. Is their a macro that could replace just the comma in
cell AW2 with a simple space?

"PCLIVE" wrote:

I think the last suggestion from Gary's Student was the best solution,
unless you're looking to only use the source cell and have your results in
that cell.
=SUBSTITUTE(LEFT(A2,FIND(",",A2 & ",",1)-1),"The ","")

"Help?" wrote in message
...
What about a Replace macro that would be just for commas?

"PCLIVE" wrote:

Oh sure, you can use that very plain and simple formula...or you could
use
this one.

=LEFT(IF(LEFT(A2,3)="The",RIGHT(A2,LEN(A2)-4),LEFT(A2,LEN(A2)-5)),FIND(",",IF(LEFT(A2,3)="The",RIGHT(A2,LEN(A2)-4),LEFT(A2,LEN(A2)-4)))-1)



"Gary''s Student" wrote in
message
...
=SUBSTITUTE(LEFT(A2,FIND(",",A2,1)-1),"The ","")

This will remove the comma and everything to the right of the comma.
It
will also remove
The
as coded it looks for a capital T and a trialing blank
--
Gary's Student


"Help?" wrote:

I currently asked the below question and received the below equation
along
with several other equations. It works great, however, it will not
accomodate
for those employer names that do not have commas or the word "The".
Can
anyone help in finding an equation that would accomodate for all three
cases?

__________________________________________________ _______



=LEFT(A2,FIND(",",A2,1)-1)
will return all the text to the left of the comma
--
Gary's Student


"Help?" wrote:

I currently have a excel macro that pulls information from the excel
columns
and adds it to the filename. Then, the macro will convert to csv
file.
A
column exists in the file called EMPLOYER NAME. An individual will
insert a
company's name in this column. This will be pulled into the
filename.
However, if a company is ABC Company, Inc. - the comma in the
filename
throws
our printing system into a loop. So, I use the equation
=LEFT(A2,FIND("
",A2))&MID(A2,FIND(" ",A2)+1,0) to only pull in the first portion of
the name
into another column and then insert the new name into the filename.
Works
good, but I am now running into the problem of the name being The
ABC
Company, Inc. The comma is not present, but the filename is The.
Does
anyone
know an equation I could use that would only pick out ABC Company
and
leave
The and the comma out?







  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default Filename Problem

YOU ARE AWESOME!! IT WORKED LIKE A CHARM. THANK YOU SO MUCH.

"Gary''s Student" wrote:

Sub one_last_try()
Dim r As Range
Set r = Range("AW2")
With r
.Value = WorksheetFunction.Substitute(.Value, ",", " ")
End With
End Sub
--
Gary's Student


"Help?" wrote:

It didn't work either. Is their a macro that could replace just the comma in
cell AW2 with a simple space?

"PCLIVE" wrote:

I think the last suggestion from Gary's Student was the best solution,
unless you're looking to only use the source cell and have your results in
that cell.
=SUBSTITUTE(LEFT(A2,FIND(",",A2 & ",",1)-1),"The ","")

"Help?" wrote in message
...
What about a Replace macro that would be just for commas?

"PCLIVE" wrote:

Oh sure, you can use that very plain and simple formula...or you could
use
this one.

=LEFT(IF(LEFT(A2,3)="The",RIGHT(A2,LEN(A2)-4),LEFT(A2,LEN(A2)-5)),FIND(",",IF(LEFT(A2,3)="The",RIGHT(A2,LEN(A2)-4),LEFT(A2,LEN(A2)-4)))-1)



"Gary''s Student" wrote in
message
...
=SUBSTITUTE(LEFT(A2,FIND(",",A2,1)-1),"The ","")

This will remove the comma and everything to the right of the comma.
It
will also remove
The
as coded it looks for a capital T and a trialing blank
--
Gary's Student


"Help?" wrote:

I currently asked the below question and received the below equation
along
with several other equations. It works great, however, it will not
accomodate
for those employer names that do not have commas or the word "The".
Can
anyone help in finding an equation that would accomodate for all three
cases?

__________________________________________________ _______



=LEFT(A2,FIND(",",A2,1)-1)
will return all the text to the left of the comma
--
Gary's Student


"Help?" wrote:

I currently have a excel macro that pulls information from the excel
columns
and adds it to the filename. Then, the macro will convert to csv
file.
A
column exists in the file called EMPLOYER NAME. An individual will
insert a
company's name in this column. This will be pulled into the
filename.
However, if a company is ABC Company, Inc. - the comma in the
filename
throws
our printing system into a loop. So, I use the equation
=LEFT(A2,FIND("
",A2))&MID(A2,FIND(" ",A2)+1,0) to only pull in the first portion of
the name
into another column and then insert the new name into the filename.
Works
good, but I am now running into the problem of the name being The
ABC
Company, Inc. The comma is not present, but the filename is The.
Does
anyone
know an equation I could use that would only pick out ABC Company
and
leave
The and the comma out?







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
filename problem in VB BrownTing[_6_] Excel Programming 1 July 25th 06 04:46 AM
Filename problem Grace[_4_] Excel Programming 15 June 13th 04 11:19 PM
Still filename problem Grace[_4_] Excel Programming 4 June 13th 04 10:09 PM
Quote in filename causes problem with Application.Run Carolyn[_2_] Excel Programming 2 February 23rd 04 12:29 AM


All times are GMT +1. The time now is 03:27 AM.

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

About Us

"It's about Microsoft Excel"