Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Wrapping cell contents in quotation marks


Baring in mind I'm still a novice at this I thought I'd post this macr
I've just built in case it might help somebody.

This forum has helped me lots of times and I'd like to do my part :))


Code
-------------------
Public Sub quotes()

Dim lastrow As Long, i As Long
Dim first As String, second As String

lastrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow

first = Cells(i, "C")
second = Chr(34) & first & Chr(34)
Cells(i, "C") = second
Next i
End Su
-------------------


The code Chr(34) represents quotation marks

If you want to change the wrapping symbols you just have to change th
number

i.e.
Chr(91) = [
Chr(93) = ]

There may be an easier way to do this but I don't know it yet

--
Damin
-----------------------------------------------------------------------
Daminc's Profile: http://www.excelforum.com/member.php...fo&userid=2707
View this thread: http://www.excelforum.com/showthread.php?threadid=48343

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default Wrapping cell contents in quotation marks

Daminic,

It's nice to see somebody posting something that somebody might find useful,
instead of just answering questions. Coud you simplify your code thus:

Sub Quotes()

Dim CheckRange As Range
Dim CheckCell As Range
Set CheckRange = ActiveSheet.Range("CheckRange2")

For Each CheckCell In CheckRange
CheckCell.Value = Chr(34) & Chr(34) & CheckCell.Value & Chr(34)
Next

End Sub

You could also replace

For Each CheckCell In CheckRange

with

for each checkcell in selection

so the macro works with whatever cells you have selected as against a
specific range.

Just a thought :-)

Pete


"Daminc" wrote:


Baring in mind I'm still a novice at this I thought I'd post this macro
I've just built in case it might help somebody.

This forum has helped me lots of times and I'd like to do my part :))


Code:
--------------------
Public Sub quotes()

Dim lastrow As Long, i As Long
Dim first As String, second As String

lastrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow

first = Cells(i, "C")
second = Chr(34) & first & Chr(34)
Cells(i, "C") = second
Next i
End Sub
--------------------


The code Chr(34) represents quotation marks

If you want to change the wrapping symbols you just have to change the
number

i.e.
Chr(91) = [
Chr(93) = ]

There may be an easier way to do this but I don't know it yet.


--
Daminc
------------------------------------------------------------------------
Daminc's Profile: http://www.excelforum.com/member.php...o&userid=27074
View this thread: http://www.excelforum.com/showthread...hreadid=483438


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default Wrapping cell contents in quotation marks

"Daminc"

Here's a quick way to produce a list of all the control characters you can
use.

Sub ControlChars()

Dim ControlCount As Integer

Range("J1").Select 'where the list is to start
For ControlCount = 1 To 255
Selection.Value = Chr(ControlCount)
Selection.Offset(0, 1).Value = "CHR(" & ControlCount & ")"
Selection.Offset(1, 0).Select
Next

End Sub

Cheers

Pete
"Daminc" wrote:


Baring in mind I'm still a novice at this I thought I'd post this macro
I've just built in case it might help somebody.

This forum has helped me lots of times and I'd like to do my part :))


Code:
--------------------
Public Sub quotes()

Dim lastrow As Long, i As Long
Dim first As String, second As String

lastrow = Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lastrow

first = Cells(i, "C")
second = Chr(34) & first & Chr(34)
Cells(i, "C") = second
Next i
End Sub
--------------------


The code Chr(34) represents quotation marks

If you want to change the wrapping symbols you just have to change the
number

i.e.
Chr(91) = [
Chr(93) = ]

There may be an easier way to do this but I don't know it yet.


--
Daminc
------------------------------------------------------------------------
Daminc's Profile: http://www.excelforum.com/member.php...o&userid=27074
View this thread: http://www.excelforum.com/showthread...hreadid=483438


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Wrapping cell contents in quotation marks


Thanks Pete, I'll copy that info into a work doc for future reference
The macro I built was for a specific problem one of my co-worker
wanted sorting out and it works for that but your adaption may b
needed if another problem comes along :

--
Damin
-----------------------------------------------------------------------
Daminc's Profile: http://www.excelforum.com/member.php...fo&userid=2707
View this thread: http://www.excelforum.com/showthread.php?threadid=48343

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
CELL return value without double quotation marks Rui Gomes Excel Worksheet Functions 1 November 14th 07 10:40 PM
add quotation marks to each cell in a column sauceraus Excel Discussion (Misc queries) 3 January 29th 07 07:08 PM
quotation marks JohnF Excel Worksheet Functions 7 February 5th 06 09:33 PM
quotation marks Hippy Excel Programming 2 November 4th 05 11:05 PM
Using quotation marks Mike Collard Excel Programming 4 July 20th 04 08:09 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"