On Nov 25, 8:09 pm, rpick60 <rpic...@yahoo.com> wrote:
> On Nov 25, 8:03 pm, Basilisk96 <basilis...@gmail.com> wrote:
>
>
>
> > On Nov 25, 8:00 pm, rpick60 <rpic...@yahoo.com> wrote:
>
> > > On Nov 25, 7:52 pm, Basilisk96 <basilis...@gmail.com> wrote:
>
> > > > On Nov 25, 7:25 pm, rpick60 <rpic...@yahoo.com> wrote:
>
> > > > > I have a simple question. I have a worksheet that has a list of item
> > > > > to be purchased that is referenced from another sheet. =Sheet1!E10
> > > > > What i want to do is keep the link but add text after the formula.
>
> > > > > My end result should be =Sheet1!E10 & " add some kind of note"
>
> > > > > How can I set up a macro to add text to the formula and allow the user
> > > > > to keep the link to sheet1?
>
> > > > It looks like you need to simply concatenate the result of the
> > > > existing formula with some additional text. Try adding this code to a
> > > > Module:
>
> > > > Public Sub AddTextToFormula()
> > > > txt = InputBox("Enter text to add to formula:")
> > > > Set rng = Selection
> > > > rng.Formula = rng.Formula & " & " & Chr(34) & Chr(32) & txt &
> > > > Chr(34)
> > > > End Sub
>
> > > > Then run AddTextToFormula as a macro. Note that this operates on the
> > > > current selected range, so be sure to select the cell of interest
> > > > before running the macro.
>
> > > > Cheers,
> > > > -Basilisk96
>
> > > Thank but hat work on a range of cells, I need it to work on a active
> > > cell
>
> > You're right. Then just use:
>
> > Public Sub AddTextToFormula()
> > txt = InputBox("Enter text to add to formula:")
> > ActiveCell.Formula = ActiveCell.Formula & " & " & Chr(34) &
> > Chr(32) & txt & Chr(34)
> > End Sub
>
> > Cheers,
> > -Basilisk96- Hide quoted text -
>
> > - Show quoted text -
>
> I get an error on this line compile error syntax error
>
> ActiveCell.Formula = ActiveCell.Formula & " & " & Chr(34) &
So do I

)
....unless I tack on the rest of the statement from the line that
follows:
Chr(32) & txt & Chr(34)
The posts unfortunately break up lines into shorter ones, hence your
error.
But just to be 100% safe (with my tongue in cheek), you can use this
version:
ActiveCell.Formula = _
ActiveCell.Formula & _
" & " & _
Chr(34) & _
Chr(32) & _
txt & _
Chr(34)
Cheers,
-Basilisk96