Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default selecting cells and getting their content into a string?

Hi all

I have a spreadsheet (Excel 2007) with text values in columns A and B
(rows 1 to 120). Is there a way to put some code in column C (rows 1-to
120) so that each cell in column C shows either a tick box or a radio
button and then by launching a separate command (a button perhaps) i get
a string with the content of the cells in column A for which I have
checked the corresponding cell in column C?

Example, my spreadsheet has:
A B C
1 cat yellow
2 dog red
3 squirrel blue
4 bird pink

then I do the ticking in column C

A B C
1 cat yellow X
2 dog red
3 squirrel blue X
4 bird pink

then I press my button and i get (in the clipboard or in cell D1) this
string "cat,squirrel", so the spreadsheet now looks like:


A B C D
1 cat yellow X cat,squirrel
2 dog red
3 squirrel blue X
4 bird pink

Any idea or example on how ro do this?

Thanks!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default selecting cells and getting their content into a string?

You can use this macro to do what you ask...

Sub MakeString()
Dim X As Long, StringOut As String
For X = 1 To 120
If Len(Cells(X, "C").Value) Then
StringOut = StringOut & Cells(X, "A") & ","
End If
Next
Range("D1") = Left(StringOut, Len(StringOut) - 1)
End Sub

To install the macro, press Alt+F11 to get into the VB editor, then click
Insert/Module from its menu bar and then copy/paste the above code into the
code window that appeared. Now, go back to your worksheet and place any
characters you want in Column C (you probably will want to use an X, but any
character or characters will work). Next, press Alt+F8, select MakeString
and click the Run button.

--
Rick (MVP - Excel)


"mocha99" wrote in message
...
Hi all

I have a spreadsheet (Excel 2007) with text values in columns A and B
(rows 1 to 120). Is there a way to put some code in column C (rows 1-to
120) so that each cell in column C shows either a tick box or a radio
button and then by launching a separate command (a button perhaps) i get a
string with the content of the cells in column A for which I have checked
the corresponding cell in column C?

Example, my spreadsheet has:
A B C
1 cat yellow
2 dog red
3 squirrel blue
4 bird pink

then I do the ticking in column C

A B C
1 cat yellow X
2 dog red
3 squirrel blue X
4 bird pink

then I press my button and i get (in the clipboard or in cell D1) this
string "cat,squirrel", so the spreadsheet now looks like:


A B C D
1 cat yellow X cat,squirrel
2 dog red
3 squirrel blue X
4 bird pink

Any idea or example on how ro do this?

Thanks!



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
Selecting all cells with content using a variable Colin Hayes Excel Discussion (Misc queries) 3 March 3rd 12 05:15 PM
Compute string content jfkaufeler Excel Discussion (Misc queries) 6 January 15th 08 10:02 PM
Excel Shortcuts - Selecting all cells with the same content G-man Excel Discussion (Misc queries) 2 January 10th 08 06:54 PM
Creating a text string by reading content in multiple cells smaruzzi Excel Worksheet Functions 3 February 8th 07 05:12 PM
Selecting a number of rows based on the content matpj[_25_] Excel Programming 3 November 25th 05 09:27 AM


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

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

About Us

"It's about Microsoft Excel"