Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Str() Why does it add a space?

Status
Not open for further replies.

nochoice

Programmer
Jun 17, 2003
72
CA
Hello,

I have a simple For loop in a Word Macro

For i = 1 To count.Value

rnga = "A" + Str(i)
rngb = "B" + Str(i)
oWbk.Sheets(1).Range(rnga).formulaR1C1 = myarray(0, i)
oWbk.Sheets(1).Range(rngb).formulaR1C1 = myarray(1, i)

Next i

My only problem is Str(i) returns the value of i as a string but it includes a space before the number so it looks like A_1 - where _ is a space.

Any suggestions?

Thanks in advance,
NoChoice

 
Str() is allowing for a possible negative sign (whether it needs to or not.

Most of us eventually figure out (or observe in other posts) that you can do this instead:
Code:
  rnga = "A" & i
  rngb = "B" & i
and it gives you what you want.

 
Thanks for the quick response.

It works well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top