PC Review


Reply
Thread Tools Rate Thread

add empty space in formula

 
 
=?Utf-8?B?Sm9vdGpl?=
Guest
Posts: n/a
 
      1st Oct 2007
Hi,

Having some trouble with inserting formula.

Sub formula()
Columns("H:H").Select
Selection.Insert Shift:=xlToRight
Range("I1").Select
Selection.Copy
Range("H1").Select
ActiveSheet.Paste
'Range("H2").Select
' Application.CutCopyMode = False
' this is the formula but I get a compile error message end of statement
'activecell.FormulaR1C1 = "=J2&" "&K2"
' I need to put a space between J2 and K2, otherwise the strings
aren't seperated with a space

End Sub


How can I solve this? Or should I
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      1st Oct 2007
activecell.FormulaR1C1 = "=J2&"" ""&K2"


demo'd from the immediate window for confidence:

? "=J2&"" ""&K2"
=J2&" "&K2

so double up double quotes when within double quotes

--
regards,
Tom Ogilvy


"Jootje" wrote:

> Hi,
>
> Having some trouble with inserting formula.
>
> Sub formula()
> Columns("H:H").Select
> Selection.Insert Shift:=xlToRight
> Range("I1").Select
> Selection.Copy
> Range("H1").Select
> ActiveSheet.Paste
> 'Range("H2").Select
> ' Application.CutCopyMode = False
> ' this is the formula but I get a compile error message end of statement
> 'activecell.FormulaR1C1 = "=J2&" "&K2"
> ' I need to put a space between J2 and K2, otherwise the strings
> aren't seperated with a space
>
> End Sub
>
>
> How can I solve this? Or should I

 
Reply With Quote
 
=?Utf-8?B?Sm9vdGpl?=
Guest
Posts: n/a
 
      2nd Oct 2007
Hmmm, still not working, this is what I get:

='I2'&" "&'J2'

"Tom Ogilvy" wrote:

> activecell.FormulaR1C1 = "=J2&"" ""&K2"
>
>
> demo'd from the immediate window for confidence:
>
> ? "=J2&"" ""&K2"
> =J2&" "&K2
>
> so double up double quotes when within double quotes
>
> --
> regards,
> Tom Ogilvy
>
>
> "Jootje" wrote:
>
> > Hi,
> >
> > Having some trouble with inserting formula.
> >
> > Sub formula()
> > Columns("H:H").Select
> > Selection.Insert Shift:=xlToRight
> > Range("I1").Select
> > Selection.Copy
> > Range("H1").Select
> > ActiveSheet.Paste
> > 'Range("H2").Select
> > ' Application.CutCopyMode = False
> > ' this is the formula but I get a compile error message end of statement
> > 'activecell.FormulaR1C1 = "=J2&" "&K2"
> > ' I need to put a space between J2 and K2, otherwise the strings
> > aren't seperated with a space
> >
> > End Sub
> >
> >
> > How can I solve this? Or should I

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      2nd Oct 2007
try:
activecell.Formula = "=J2&"" ""&K2"



Jootje wrote:
>
> Hmmm, still not working, this is what I get:
>
> ='I2'&" "&'J2'
>
> "Tom Ogilvy" wrote:
>
> > activecell.FormulaR1C1 = "=J2&"" ""&K2"
> >
> >
> > demo'd from the immediate window for confidence:
> >
> > ? "=J2&"" ""&K2"
> > =J2&" "&K2
> >
> > so double up double quotes when within double quotes
> >
> > --
> > regards,
> > Tom Ogilvy
> >
> >
> > "Jootje" wrote:
> >
> > > Hi,
> > >
> > > Having some trouble with inserting formula.
> > >
> > > Sub formula()
> > > Columns("H:H").Select
> > > Selection.Insert Shift:=xlToRight
> > > Range("I1").Select
> > > Selection.Copy
> > > Range("H1").Select
> > > ActiveSheet.Paste
> > > 'Range("H2").Select
> > > ' Application.CutCopyMode = False
> > > ' this is the formula but I get a compile error message end of statement
> > > 'activecell.FormulaR1C1 = "=J2&" "&K2"
> > > ' I need to put a space between J2 and K2, otherwise the strings
> > > aren't seperated with a space
> > >
> > > End Sub
> > >
> > >
> > > How can I solve this? Or should I


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?Sm9vdGpl?=
Guest
Posts: n/a
 
      3rd Oct 2007
AH! Thanks, that's it!

"Dave Peterson" wrote:

> try:
> activecell.Formula = "=J2&"" ""&K2"
>
>
>
> Jootje wrote:
> >
> > Hmmm, still not working, this is what I get:
> >
> > ='I2'&" "&'J2'
> >
> > "Tom Ogilvy" wrote:
> >
> > > activecell.FormulaR1C1 = "=J2&"" ""&K2"
> > >
> > >
> > > demo'd from the immediate window for confidence:
> > >
> > > ? "=J2&"" ""&K2"
> > > =J2&" "&K2
> > >
> > > so double up double quotes when within double quotes
> > >
> > > --
> > > regards,
> > > Tom Ogilvy
> > >
> > >
> > > "Jootje" wrote:
> > >
> > > > Hi,
> > > >
> > > > Having some trouble with inserting formula.
> > > >
> > > > Sub formula()
> > > > Columns("H:H").Select
> > > > Selection.Insert Shift:=xlToRight
> > > > Range("I1").Select
> > > > Selection.Copy
> > > > Range("H1").Select
> > > > ActiveSheet.Paste
> > > > 'Range("H2").Select
> > > > ' Application.CutCopyMode = False
> > > > ' this is the formula but I get a compile error message end of statement
> > > > 'activecell.FormulaR1C1 = "=J2&" "&K2"
> > > > ' I need to put a space between J2 and K2, otherwise the strings
> > > > aren't seperated with a space
> > > >
> > > > End Sub
> > > >
> > > >
> > > > How can I solve this? Or should I

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: empty space Carey Frisch [MVP] Windows Vista General Discussion 6 9th Jul 2008 11:27 PM
Re: empty space Bob I Windows XP General 2 28th May 2008 03:12 AM
Re: empty space Unknown Windows XP General 0 27th May 2008 03:31 PM
Empty space accessman2 Microsoft Excel Discussion 0 9th Oct 2005 08:56 PM
Empty Space Peter Microsoft Frontpage 2 29th Apr 2004 10:05 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:39 PM.