Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excell VBA Macro with Symbols

I need to take data out of column A and put that with all commas but i
need to add the following symbol ', example

11111
11112
11113
11114

I need to create a macro that takes this column and create it as follows
11111,11112,11113,11114

but i need the symbol added so that it looks as follows:
'11111','11112','11113','11114'

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,646
Default Excell VBA Macro with Symbols

Sub test()
Dim colA As Range, cA As Range
Set colA = Range("A1:A4")
result = "'"
For Each cA In colA
result = result & cA & "','"
Next cA
result = Left(result, Len(result) - 2)
Range("B1").Value = result
End Sub

Adjust Range("A1:A4")!
It puts the result in B1!

Regards,
Stefi

€˛Lynette Olivier€¯ ezt Ć*rta:

I need to take data out of column A and put that with all commas but i
need to add the following symbol ', example

11111
11112
11113
11114

I need to create a macro that takes this column and create it as follows
11111,11112,11113,11114

but i need the symbol added so that it looks as follows:
'11111','11112','11113','11114'

*** Sent via Developersdex http://www.developersdex.com ***

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Excell VBA Macro with Symbols

Another one, adapt to your needs -

Sub test()
Dim nRows As Long, nCols As Long
Dim s As String, sMsg As String
Dim rng As Range
Dim arr

Set rng = Range("A1:A4") ' < change, eg set rng=Selection

With rng
nRows = .Rows.Count
nCols = .Columns.Count
arr = .Value
End With

If nRows 1 And nCols 1 Then
sMsg = "Only select cells in a single row or column"
ElseIf nRows = 1 And nCols = 1 Then
sMsg = "Only one cell selected"
ElseIf nRows 256 Then
sMsg = "too many cells selected"
ElseIf nCols = 1 Then
arr = Application.Transpose(arr)
End If

If Len(sMsg) Then
MsgBox sMsg
Else
s = Join(arr, ",")
If IsNumeric(s) Then s = "'" & s
Range("B1") = s
End If

End Sub


Regards,
Peter T
"Lynette Olivier" wrote in message
...
I need to take data out of column A and put that with all commas but i
need to add the following symbol ', example

11111
11112
11113
11114

I need to create a macro that takes this column and create it as follows
11111,11112,11113,11114

but i need the symbol added so that it looks as follows:
'11111','11112','11113','11114'

*** Sent via Developersdex http://www.developersdex.com ***



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
Symbols on the keyboard are not the symbols on the screen.... Lisha Excel Discussion (Misc queries) 2 May 22nd 10 07:29 AM
How to insert maths symbols into an excell function? Maths symbols on excell Excel Worksheet Functions 1 May 16th 10 08:53 PM
How do you insert wingdings symbols using VBA macro? mamabear Excel Programming 2 July 18th 07 07:38 AM
Inserting Symbols via a macro GRussell31 Excel Programming 9 March 4th 06 05:14 PM
converting Lotus 123 macro to Excell macro mark h Excel Discussion (Misc queries) 6 July 11th 05 01:28 PM


All times are GMT +1. The time now is 02:12 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"