Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Append name in the same cell with ' '

please anyone can help on:
1.
Write a macro to obtain all the below names within single quotes &
separated by comma in one cell. The data can have any number of rows.
Define Dynamic range

green
blue
yellow

i.e,
in a single cell as
'green', 'blue', 'yellow'

2.
Write a macro which fills the blanks with the respective Course Name
Ids in Column A

ie.
1234 white
blue
yellow
4568 green
red


fill all the blanks column with the respective number

please help
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Append name in the same cell with ' '

You didn't tell us starting cells or destination cells, so I had to guess;
change the StartCell, Destination and ColLetter to match your actual
situation. The CombineCells macro answer your first question and the
FillInTheBlanks macro answers your second question.

Sub CombineCells()
Dim X As Long, LastRow As Long, StartCell As Range, Destination As Range
Set StartCell = Range("A2")
Set Destination = Range("B2")
LastRow = Cells(Rows.Count, StartCell.Column).End(xlUp).Row
Destination.Value2 = "''" & Join(WorksheetFunction.Transpose( _
Range(StartCell, Cells(LastRow, _
StartCell.Column))), "', '") & "'"
End Sub

Sub FillInTheBlanks()
Dim Area As Range, LastRow As Long
Const ColLetter As String = "A"
On Error Resume Next
LastRow = Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlFormulas).Row
For Each Area In Columns(ColLetter)(1).Resize(LastRow). _
SpecialCells(xlCellTypeBlanks).Areas
Area.Value = Area(1).Offset(-1).Value
Next
End Sub

I couldn't decide if your questions were a homework assignment or not. Just
so you know... if it is a homework assignment, then I can **absolutely
guarantee** your instructor will know you didn't write the above code.

--
Rick (MVP - Excel)


"Ratheesh" wrote in message
...
please anyone can help on:
1.
Write a macro to obtain all the below names within single quotes &
separated by comma in one cell. The data can have any number of rows.
Define Dynamic range

green
blue
yellow

i.e,
in a single cell as
'green', 'blue', 'yellow'

2.
Write a macro which fills the blanks with the respective Course Name
Ids in Column A

ie.
1234 white
blue
yellow
4568 green
red


fill all the blanks column with the respective number

please help


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Append name in the same cell with ' '

On Nov 27, 6:50*pm, "Don Guillett" wrote:
Homework?

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"Ratheesh" wrote in message

...



please anyone can help on:
1.
Write a macro to obtain all the below names within single quotes &
separated by comma in one cell. The data can have any number of rows.
Define Dynamic range


green
blue
yellow


i.e,
in a single cell as
'green', 'blue', 'yellow'


2.
Write a macro which fills the blanks with the respective Course Name
Ids in Column A


ie.
1234 white
* * * *blue
* * * *yellow
4568 green
* * * *red


fill all the blanks column with the respective number


please help- Hide quoted text -


- Show quoted text -


Hi -

Actually I am a bigginer in VBA, but you are right here, I was having
2 test and it should complete within 30 minutes ! I was really
worried, whether I can complete or not ?
BUT NOW I AM SO HAPPY.... I COMPLETED WITHIN 30 MINUTES WITH MY OWN
CODING !!!
If I need to paste 1 number to all the cell then it would be easy, but
here I need to paste the value for corresponding value to the below
blank cells eg:,
A B
2323 BLUE
YELLLOW
RED
4569 GREEN
ORANGE here, 2323 for Yellow and Red (A Column) & 4569 for
Orange, here it has to stop...

But as per my coding, it will continue till the end of the column,
thats why I restricted in Range("A1:A33"), I tried to take the
rows.count for B column, but I couldnt complete within the time, so I
used the range !!!
In this .FillDown I got, when I recorded for Ctrl + D !

Sub fillblanks()
For Each x In Range("A1:A33")
If x = "" Then x.FillDown
Next x
End Sub


This is for my first test, this came in my mind immediately, coz, I
was doing egs For Each loop many times last night !

Sub appendline()
For Each x In Range("A:A")
If x < "" Then
Cells(3, 2).Value = "'" & Cells(3, 2).Value & x & "'," ' end
with a comma :( - again one code to remove that !
End If
Next x
End Sub



Cheeeeeeers
Ratheesh
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
Append to a cell diacci1st Excel Programming 3 June 5th 09 03:19 AM
Append existing cell value Gnerks Excel Programming 2 October 23rd 07 11:41 AM
Append character to cell glenn[_3_] Excel Programming 2 September 27th 07 11:17 PM
File Append Row by Cell value Djmask[_8_] Excel Programming 3 August 22nd 05 04:37 AM
macro to append one cell to another billbeecham Excel Programming 4 November 10th 04 01:23 PM


All times are GMT +1. The time now is 05:46 PM.

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"