Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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









  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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











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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
How to make a button VBA code reference other VBA code subroutines??? gunman[_9_] Excel Programming 4 September 27th 05 01:01 AM
run code on opening workbook and apply code to certain sheets Jane Excel Programming 7 August 8th 05 09:15 AM
stubborn Excel crash when editing code with code, one solution Brian Murphy Excel Programming 0 February 20th 05 05:56 AM


All times are GMT +1. The time now is 03:15 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"