PC Review


Reply
Thread Tools Rate Thread

Adding quotation marks to each line of cell contents with carriagereturns

 
 
Will
Guest
Posts: n/a
 
      22nd Jul 2009
Hi All,

I am using Excel as an interface to import some process data into a
modelling tool. One of the limitations of the modelling tool is that
any data in the sheet has to be enclosed in quote or speech marks to
import the data.

I have only just discovered this and have a lot of data that has been
imported into the tool which is now unreadable.

Can anyone provide some VBA that will add speech marks i.e. " sample
text " to each line of text in each cell.

Thanks in advance.

Will
 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      22nd Jul 2009
> each line of text in each cell.

If you mean you might have multiple lines in a cell separated with LineFeeds
try the following. Select cells in a column and ensure there are empy cells
to the right, run the macro.

Sub QuoteEm()
Dim i as Long
Dim va
Dim rCell As Range

For Each rCell In Selection
va = Split(rCell, vbLf)
For i = LBound(va) To UBound(va)
va(i) = Chr(34) & va(i) & Chr(34)
Next
rCell.Offset(, 1) = Join(va, vbLf)
Next

End Sub

Regards,
Peter T


"Will" <(E-Mail Removed)> wrote in message
news:2b7e718e-55f9-4c35-8a19-(E-Mail Removed)...
> Hi All,
>
> I am using Excel as an interface to import some process data into a
> modelling tool. One of the limitations of the modelling tool is that
> any data in the sheet has to be enclosed in quote or speech marks to
> import the data.
>
> I have only just discovered this and have a lot of data that has been
> imported into the tool which is now unreadable.
>
> Can anyone provide some VBA that will add speech marks i.e. " sample
> text " to each line of text in each cell.
>
> Thanks in advance.
>
> Will



 
Reply With Quote
 
Patrick Molloy
Guest
Posts: n/a
 
      22nd Jul 2009
Sub cellquotes()
Dim cell As Range
For Each cell In Range("A1:A100").Cells
If cell.Value <> "" Then
cell.Value = Chr(34) & cell.Value & Chr(34)
End If
Next
End Sub

"Peter T" <peter_t@discussions> wrote in message
news:(E-Mail Removed)...
>> each line of text in each cell.

>
> If you mean you might have multiple lines in a cell separated with
> LineFeeds try the following. Select cells in a column and ensure there are
> empy cells to the right, run the macro.
>
> Sub QuoteEm()
> Dim i as Long
> Dim va
> Dim rCell As Range
>
> For Each rCell In Selection
> va = Split(rCell, vbLf)
> For i = LBound(va) To UBound(va)
> va(i) = Chr(34) & va(i) & Chr(34)
> Next
> rCell.Offset(, 1) = Join(va, vbLf)
> Next
>
> End Sub
>
> Regards,
> Peter T
>
>
> "Will" <(E-Mail Removed)> wrote in message
> news:2b7e718e-55f9-4c35-8a19-(E-Mail Removed)...
>> Hi All,
>>
>> I am using Excel as an interface to import some process data into a
>> modelling tool. One of the limitations of the modelling tool is that
>> any data in the sheet has to be enclosed in quote or speech marks to
>> import the data.
>>
>> I have only just discovered this and have a lot of data that has been
>> imported into the tool which is now unreadable.
>>
>> Can anyone provide some VBA that will add speech marks i.e. " sample
>> text " to each line of text in each cell.
>>
>> Thanks in advance.
>>
>> Will

>
>

 
Reply With Quote
 
Will
Guest
Posts: n/a
 
      22nd Jul 2009
On 22 July, 11:09, "Patrick Molloy" <patrick_mol...@hotmail.com>
wrote:
> Sub cellquotes()
> Dim cell As Range
> For Each cell In Range("A1:A100").Cells
> * * If cell.Value <> "" Then
> * * * * cell.Value = Chr(34) & cell.Value & Chr(34)
> * * End If
> Next
> End Sub
>
> "Peter T" <peter_t@discussions> wrote in message
>
> news:(E-Mail Removed)...
>
>
>
> >> each line of text in each cell.

>
> > If you mean you might have multiple lines in a cell separated with
> > LineFeeds try the following. Select cells in a column and ensure there are
> > empy cells to the right, run the macro.

>
> > Sub QuoteEm()
> > Dim i as Long
> > Dim va
> > Dim rCell As Range

>
> > * *For Each rCell In Selection
> > * * * *va = Split(rCell, vbLf)
> > * * * *For i = LBound(va) To UBound(va)
> > * * * * * *va(i) = Chr(34) & va(i) & Chr(34)
> > * * * *Next
> > * * * *rCell.Offset(, 1) = Join(va, vbLf)
> > * *Next

>
> > End Sub

>
> > Regards,
> > Peter T

>
> > "Will" <willc...@yahoo.com> wrote in message
> >news:2b7e718e-55f9-4c35-8a19-(E-Mail Removed)...
> >> Hi All,

>
> >> I am using Excel as an interface to import some process data into a
> >> modelling tool. *One of the limitations of the modelling tool is that
> >> any data in the sheet has to be enclosed in quote or speech marks to
> >> import the data.

>
> >> I have only just discovered this and have a lot of data that has been
> >> imported into the tool which is now unreadable.

>
> >> Can anyone provide some VBA that will add speech marks i.e. " sample
> >> text " to each line of text in each cell.

>
> >> Thanks in advance.

>
> >> Will- Hide quoted text -

>
> - Show quoted text -


Great, thanks Peter and Patrick
 
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
Adding Quotation Marks to Data already in Mulitple Cells =?Utf-8?B?Um9u?= Microsoft Excel Setup 3 23rd Feb 2007 06:15 PM
Adding Quotation marks to populated fields pentatonic145 Microsoft Excel Discussion 5 17th Apr 2006 11:06 PM
Wrapping cell contents in quotation marks Daminc Microsoft Excel Programming 3 9th Nov 2005 11:27 AM
Adding quotation marks =?Utf-8?B?WmlhZm9yZXZlcg==?= Microsoft Word Document Management 1 1st Dec 2004 09:13 PM
adding quotation marks to a string? vince Microsoft C# .NET 1 31st Aug 2003 12:36 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:13 AM.