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

sub add_strings()
A = "4="
B = CELLS(ROW,"B") 'THE CONTENT OF THE CELLS IS 2
C= A + STR$(B)

END SUB

The result is 4= 2

I don't want the space between the 4= & the 2
Is there a way of combining the two, but removing the
leading space ??
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default adding strings

Julian,

Try

Sub add_strings()
A = "4="
B = Cells(1, "B") 'THE CONTENT OF THE CELLS IS 2
C = A + Trim(Str$(B))

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"julian brotherton" wrote in message
...
sub add_strings()
A = "4="
B = CELLS(ROW,"B") 'THE CONTENT OF THE CELLS IS 2
C= A + STR$(B)

END SUB

The result is 4= 2

I don't want the space between the 4= & the 2
Is there a way of combining the two, but removing the
leading space ??



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default adding strings

Ctrl+H

Find = one space
Replace = none entry

Replace All



-----Original Message-----
sub add_strings()
A = "4="
B = CELLS(ROW,"B") 'THE CONTENT OF THE CELLS IS 2
C= A + STR$(B)

END SUB

The result is 4= 2

I don't want the space between the 4= & the 2
Is there a way of combining the two, but removing the
leading space ??
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default adding strings

Thanks. Worked fine.
Why doesn't the help file point to this simple function ??

Julian B


-----Original Message-----
Julian,

Try

Sub add_strings()
A = "4="
B = Cells(1, "B") 'THE CONTENT OF THE CELLS IS 2
C = A + Trim(Str$(B))

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"julian brotherton" wrote

in message
...
sub add_strings()
A = "4="
B = CELLS(ROW,"B") 'THE CONTENT OF THE CELLS IS 2
C= A + STR$(B)

END SUB

The result is 4= 2

I don't want the space between the 4= & the 2
Is there a way of combining the two, but removing the
leading space ??



.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default adding strings

Actually, you don't need str$. If the cell actually contains a number
(which is why you would use str$ and help does say that str$ puts a space in
for the sign), you wouldn't need trim.

Both Trim and Str/str$ are documented in Excel VBA help.

Sub add_strings()
A = "4="
B = Cells(1, "B") 'THE CONTENT OF THE CELLS IS 2
C = A & B
End Sub

Sub add_strings()
A = "4="
B = Cells(1, "B") 'THE CONTENT OF THE CELLS IS 2
C = A & cStr(B)

End Sub

would work equally as well with a number in the cell.

--
Regards,
Tom Ogilvy





"JULIAN BROTHERTON" wrote in message
...
Thanks. Worked fine.
Why doesn't the help file point to this simple function ??

Julian B


-----Original Message-----
Julian,

Try

Sub add_strings()
A = "4="
B = Cells(1, "B") 'THE CONTENT OF THE CELLS IS 2
C = A + Trim(Str$(B))

End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"julian brotherton" wrote

in message
...
sub add_strings()
A = "4="
B = CELLS(ROW,"B") 'THE CONTENT OF THE CELLS IS 2
C= A + STR$(B)

END SUB

The result is 4= 2

I don't want the space between the 4= & the 2
Is there a way of combining the two, but removing the
leading space ??



.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default adding strings

Format$(B) will also eliminate the space.

On Tue, 7 Oct 2003 12:28:10 +0100, "Bob Phillips" wrote:

Julian,

Try

Sub add_strings()
A = "4="
B = Cells(1, "B") 'THE CONTENT OF THE CELLS IS 2
C = A + Trim(Str$(B))

End Sub


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default adding strings

so will just

A & B

--
Regards,
Tom Ogilvy

"Myrna Larson" wrote in message
...
Format$(B) will also eliminate the space.

On Tue, 7 Oct 2003 12:28:10 +0100, "Bob Phillips"

wrote:

Julian,

Try

Sub add_strings()
A = "4="
B = Cells(1, "B") 'THE CONTENT OF THE CELLS IS 2
C = A + Trim(Str$(B))

End Sub




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
find and replace numeric strings in larger text strings Mr Molio Excel Worksheet Functions 8 November 9th 11 05:17 PM
Assigning strings number values and adding them together JRD Excel Worksheet Functions 2 June 23rd 09 10:08 PM
Adding strings using macros ultrarev Excel Worksheet Functions 5 December 19th 08 09:32 PM
How to find number of pairs of strings from list of strings? greg_overholt Excel Worksheet Functions 5 January 27th 06 10:42 PM
How can I count strings within strings Paul W Excel Worksheet Functions 4 June 14th 05 12:39 PM


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