Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
split post code (zip code) out of cell that includes full address | Excel Discussion (Misc queries) | |||
Drop Down/List w/Code and Definition, only code entered when selec | Excel Worksheet Functions | |||
How to make a button VBA code reference other VBA code subroutines??? | Excel Programming | |||
run code on opening workbook and apply code to certain sheets | Excel Programming | |||
stubborn Excel crash when editing code with code, one solution | Excel Programming |