ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   need some code help please (https://www.excelbanter.com/excel-programming/344994-need-some-code-help-please.html)

Gary Keramidas

need some code help please
 
in the following code, i get the name from another sheet. if it's blank, it
just gives me the name, but if there is another name that goes in the same
cell, i put a / between them

how would i put a chr(10) after every 2nd name, so only 2 fit on a line in
each cell.


If .Value = "" Then
.Value = Left(Fname, Len(Fname) - 4)
Else
.Value = .Value & "/" & Left(Fname, Len(Fname) - 4)
End If
--


Gary




Bob Phillips[_6_]

need some code help please
 
If .Value = "" Then
.Value = Left(Fname, Len(Fname) - 4)
Else
c = Len(.Value) - Len(Replace(.Value, "\", ""))
If c Mod 2 = 1 Then
.Value = .Value & "/" vbNewline
Else
.Value = .Value & "/"
End If
.Value = .Value & Left(Fname, Len(Fname) - 4)
End If
--


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
in the following code, i get the name from another sheet. if it's blank,

it
just gives me the name, but if there is another name that goes in the same
cell, i put a / between them

how would i put a chr(10) after every 2nd name, so only 2 fit on a line in
each cell.


If .Value = "" Then
.Value = Left(Fname, Len(Fname) - 4)
Else
.Value = .Value & "/" & Left(Fname, Len(Fname) - 4)
End If
--


Gary






Gary Keramidas

need some code help please
 
thanks bob, had to make a couple changes, but it seems to work fine.

i was using this, Len(.Value) - Len(Replace(.Value, "/", "")) = 1 , but you
can see i was not using the mod function.

anyway, what i changed was:

1. you had a typo, a backslash instead of a slash in the formula.

2. the vbnewline didn't have the & in front of it and gave me the little
square box in the cell, so i changed it to chr(10)

thanks again.


--


Gary


"Bob Phillips" wrote in message
...
If .Value = "" Then
.Value = Left(Fname, Len(Fname) - 4)
Else
c = Len(.Value) - Len(Replace(.Value, "\", ""))
If c Mod 2 = 1 Then
.Value = .Value & "/" vbNewline
Else
.Value = .Value & "/"
End If
.Value = .Value & Left(Fname, Len(Fname) - 4)
End If
--


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
in the following code, i get the name from another sheet. if it's blank,

it
just gives me the name, but if there is another name that goes in the
same
cell, i put a / between them

how would i put a chr(10) after every 2nd name, so only 2 fit on a line
in
each cell.


If .Value = "" Then
.Value = Left(Fname, Len(Fname) - 4)
Else
.Value = .Value & "/" & Left(Fname, Len(Fname) - 4)
End If
--


Gary








Bob Phillips[_6_]

need some code help please
 
Sorry about that, in my testing I just cut code to test for the number of
slashes, then added the rest in the posting.

Glad you sorted it.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
thanks bob, had to make a couple changes, but it seems to work fine.

i was using this, Len(.Value) - Len(Replace(.Value, "/", "")) = 1 , but

you
can see i was not using the mod function.

anyway, what i changed was:

1. you had a typo, a backslash instead of a slash in the formula.

2. the vbnewline didn't have the & in front of it and gave me the little
square box in the cell, so i changed it to chr(10)

thanks again.


--


Gary


"Bob Phillips" wrote in message
...
If .Value = "" Then
.Value = Left(Fname, Len(Fname) - 4)
Else
c = Len(.Value) - Len(Replace(.Value, "\", ""))
If c Mod 2 = 1 Then
.Value = .Value & "/" vbNewline
Else
.Value = .Value & "/"
End If
.Value = .Value & Left(Fname, Len(Fname) - 4)
End If
--


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
in the following code, i get the name from another sheet. if it's

blank,
it
just gives me the name, but if there is another name that goes in the
same
cell, i put a / between them

how would i put a chr(10) after every 2nd name, so only 2 fit on a line
in
each cell.


If .Value = "" Then
.Value = Left(Fname, Len(Fname) - 4)
Else
.Value = .Value & "/" & Left(Fname, Len(Fname) - 4)
End If
--


Gary










Gary Keramidas

need some code help please
 
that's fine, i need the practice<g. you gave me what i needed.

--


Gary


"Bob Phillips" wrote in message
...
Sorry about that, in my testing I just cut code to test for the number of
slashes, then added the rest in the posting.

Glad you sorted it.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
thanks bob, had to make a couple changes, but it seems to work fine.

i was using this, Len(.Value) - Len(Replace(.Value, "/", "")) = 1 , but

you
can see i was not using the mod function.

anyway, what i changed was:

1. you had a typo, a backslash instead of a slash in the formula.

2. the vbnewline didn't have the & in front of it and gave me the little
square box in the cell, so i changed it to chr(10)

thanks again.


--


Gary


"Bob Phillips" wrote in message
...
If .Value = "" Then
.Value = Left(Fname, Len(Fname) - 4)
Else
c = Len(.Value) - Len(Replace(.Value, "\", ""))
If c Mod 2 = 1 Then
.Value = .Value & "/" vbNewline
Else
.Value = .Value & "/"
End If
.Value = .Value & Left(Fname, Len(Fname) - 4)
End If
--


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
in the following code, i get the name from another sheet. if it's

blank,
it
just gives me the name, but if there is another name that goes in the
same
cell, i put a / between them

how would i put a chr(10) after every 2nd name, so only 2 fit on a
line
in
each cell.


If .Value = "" Then
.Value = Left(Fname, Len(Fname) - 4)
Else
.Value = .Value & "/" & Left(Fname, Len(Fname) - 4)
End If
--


Gary













All times are GMT +1. The time now is 01:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com