Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Spaces in VBA
Excel 2002, WinXP
Say that I have two cells, A1 & B1, with entries in each. I want to concatenate those two values in, say C1. But I want a number of spaces between them. That's easy to do if the number of spaces is fixed. But I have a situation where the number of spaces is a variable, say NumSpaces. How do I code the concatenation? Something like: Range("C1").Value=[A1].Value & NumSpaces??? & [B1].Value Thanks for your help. Otto |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Spaces in VBA
Hi Otto,
One way: Sub Tester() Dim NumSpaces As Long NumSpaces = 10 Range("C1").Value = [A1].Value & _ Application.Rept(" ", NumSpaces) & [B1].Value End Sub --- Regards, Norman "Otto Moehrbach" wrote in message ... Excel 2002, WinXP Say that I have two cells, A1 & B1, with entries in each. I want to concatenate those two values in, say C1. But I want a number of spaces between them. That's easy to do if the number of spaces is fixed. But I have a situation where the number of spaces is a variable, say NumSpaces. How do I code the concatenation? Something like: Range("C1").Value=[A1].Value & NumSpaces??? & [B1].Value Thanks for your help. Otto |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Spaces in VBA
One way is to have a string of spaces at least as long as you will ever
need, then select part of this. spaces = " " Range("C1").Value = Range("A1") & Left(spaces, Numspaces) & Range("B1") I assume you get NumSpaces from elsewhere. -- Ian -- "Otto Moehrbach" wrote in message ... Excel 2002, WinXP Say that I have two cells, A1 & B1, with entries in each. I want to concatenate those two values in, say C1. But I want a number of spaces between them. That's easy to do if the number of spaces is fixed. But I have a situation where the number of spaces is a variable, say NumSpaces. How do I code the concatenation? Something like: Range("C1").Value=[A1].Value & NumSpaces??? & [B1].Value Thanks for your help. Otto |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Spaces in VBA
range("c1").value = range("a1").value & space(numspaces) & range("b1").value
Otto Moehrbach wrote: Excel 2002, WinXP Say that I have two cells, A1 & B1, with entries in each. I want to concatenate those two values in, say C1. But I want a number of spaces between them. That's easy to do if the number of spaces is fixed. But I have a situation where the number of spaces is a variable, say NumSpaces. How do I code the concatenation? Something like: Range("C1").Value=[A1].Value & NumSpaces??? & [B1].Value Thanks for your help. Otto -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Spaces in VBA
Norman, Ian, Dave
Thanks for your help with this. Otto "Otto Moehrbach" wrote in message ... Excel 2002, WinXP Say that I have two cells, A1 & B1, with entries in each. I want to concatenate those two values in, say C1. But I want a number of spaces between them. That's easy to do if the number of spaces is fixed. But I have a situation where the number of spaces is a variable, say NumSpaces. How do I code the concatenation? Something like: Range("C1").Value=[A1].Value & NumSpaces??? & [B1].Value Thanks for your help. Otto |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how do I remove leading spaces and leave the remianing spaces w | Excel Worksheet Functions | |||
spaces not recognized as spaces | Excel Worksheet Functions | |||
ADD SPACES | Excel Programming | |||
A better way to get rid of spaces | Excel Programming | |||
Help copying a range with spaces to a range without spaces | Excel Programming |