Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro to append one cell to another


Hey all....

I have never used macros before, but here goes....

I have alot of data that looks like this ( the dashes are for spacin
purposes since html is off in postings):

----A------------B--------------C
1 sample----data---------example
2 ------------more
3 sample----data---------example
4 -------------more

(no, it's not all the same info, nor always in the same place or
would use a recorded macro)

what I need is a macro to see that A2 is empty and take cell B2 an
append the contents of cell B2 to B1 so that B1 says "data more
instead of just "data"

and do this for the whole worksheet

I have been trying to look into copy and paste for macros, but
straight "copy" and "paste" won't work as it will overwrite the curren
contents of the cell being pasted to.

I have thousands upon thousands of lines I would like to combin
without having to do it all by hand.

Any ideas? Remember, I'm a newbie to excel, but not so new I can'
comprehend... thanks

Bil

--
billbeecha
-----------------------------------------------------------------------
billbeecham's Profile: http://www.excelforum.com/member.php...fo&userid=1628
View this thread: http://www.excelforum.com/showthread.php?threadid=27688

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default macro to append one cell to another

in D1 type his
=IF(A2="",B1&B2,B1)

copy D1 down to the end of the column

then either you can delete B column according to your need or copy D column
to B column

billbeecham wrote in message
...

Hey all....

I have never used macros before, but here goes....

I have alot of data that looks like this ( the dashes are for spacing
purposes since html is off in postings):

----A------------B--------------C
1 sample----data---------example
2 ------------more
3 sample----data---------example
4 -------------more

(no, it's not all the same info, nor always in the same place or I
would use a recorded macro)

what I need is a macro to see that A2 is empty and take cell B2 and
append the contents of cell B2 to B1 so that B1 says "data more"
instead of just "data"

and do this for the whole worksheet

I have been trying to look into copy and paste for macros, but a
straight "copy" and "paste" won't work as it will overwrite the current
contents of the cell being pasted to.

I have thousands upon thousands of lines I would like to combine
without having to do it all by hand.

Any ideas? Remember, I'm a newbie to excel, but not so new I can't
comprehend... thanks

Bill


--
billbeecham
------------------------------------------------------------------------
billbeecham's Profile:

http://www.excelforum.com/member.php...o&userid=16286
View this thread: http://www.excelforum.com/showthread...hreadid=276881



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default macro to append one cell to another

Sub SAMPLEDATAMORE()
Range("B1").Select
Do Until ActiveCell.Value = ""
If ActiveCell.Offset(0, -1).Value = "" Then
ActiveCell.Offset(-1, 0).Value = ActiveCell.Offset(-1, 0).Value + " " +
ActiveCell.Value
ActiveCell.Value = ""
End If
ActiveCell.Offset(1, 0).Select
Loop
End Sub

This is if all of col B has a value if not it will help you get on track
R
PETE

--
(][ This Email has been scanned by Norton AntiVirus. ][)
"billbeecham" wrote in message
...

Hey all....

I have never used macros before, but here goes....

I have alot of data that looks like this ( the dashes are for spacing
purposes since html is off in postings):

----A------------B--------------C
1 sample----data---------example
2 ------------more
3 sample----data---------example
4 -------------more

(no, it's not all the same info, nor always in the same place or I
would use a recorded macro)

what I need is a macro to see that A2 is empty and take cell B2 and
append the contents of cell B2 to B1 so that B1 says "data more"
instead of just "data"

and do this for the whole worksheet

I have been trying to look into copy and paste for macros, but a
straight "copy" and "paste" won't work as it will overwrite the current
contents of the cell being pasted to.

I have thousands upon thousands of lines I would like to combine
without having to do it all by hand.

Any ideas? Remember, I'm a newbie to excel, but not so new I can't
comprehend... thanks

Bill


--
billbeecham
------------------------------------------------------------------------
billbeecham's Profile:
http://www.excelforum.com/member.php...o&userid=16286
View this thread: http://www.excelforum.com/showthread...hreadid=276881



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default macro to append one cell to another


I doubt that would solve his problem, as he says that the data is no
uniform. Infact something similar was discussed on this forum, excep
instead of append, rows were inserted. check thread
http://excelforum.com/showthread.php?t=276521

Maybe something like

Dim cRows As Long
Dim i As Long

cRows = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 to cRows
if IsEmpty(Cells(i, "A")) then
for k = i to j step -1
cells(j,"B")=cells(j,"B") & " " & cells(i, "B")
next
end if
j = i
Next i

Haven't tested it, but should work

--
mangesh_yada

-----------------------------------------------------------------------
mangesh_yadav's Profile: http://www.excelforum.com/member.php...fo&userid=1047
View this thread: http://www.excelforum.com/showthread.php?threadid=27688

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default macro to append one cell to another

Sub SAMPLEDATAMORE()
Range("B1").Select
Do Until ActiveCell.Value = ""
If ActiveCell.Offset(0, -1).Value = "" Then
ActiveCell.Offset(-1, 0).Value = ActiveCell.Offset(-1, 0).Value + " " +
ActiveCell.Value
ActiveCell.Value = ""
End If
ActiveCell.Offset(1, 0).Select
Loop
End Sub

This is if all of col B has a value if not it will help you get on track
R
PETE


--
(][ This Email has been scanned by Norton AntiVirus. ][)
"billbeecham" wrote in message
...

Hey all....

I have never used macros before, but here goes....

I have alot of data that looks like this ( the dashes are for spacing
purposes since html is off in postings):

----A------------B--------------C
1 sample----data---------example
2 ------------more
3 sample----data---------example
4 -------------more

(no, it's not all the same info, nor always in the same place or I
would use a recorded macro)

what I need is a macro to see that A2 is empty and take cell B2 and
append the contents of cell B2 to B1 so that B1 says "data more"
instead of just "data"

and do this for the whole worksheet

I have been trying to look into copy and paste for macros, but a
straight "copy" and "paste" won't work as it will overwrite the current
contents of the cell being pasted to.

I have thousands upon thousands of lines I would like to combine
without having to do it all by hand.

Any ideas? Remember, I'm a newbie to excel, but not so new I can't
comprehend... thanks

Bill


--
billbeecham
------------------------------------------------------------------------
billbeecham's Profile:
http://www.excelforum.com/member.php...o&userid=16286
View this thread: http://www.excelforum.com/showthread...hreadid=276881



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
Help for excel macro ( to append records) Sunil Somani Excel Discussion (Misc queries) 1 September 29th 09 06:05 PM
Copy and Append Macro Excel Help! Excel Discussion (Misc queries) 2 April 7th 08 05:39 PM
Macro that will Cut rows and then insert-copy or append rod Excel Discussion (Misc queries) 3 October 21st 06 04:50 PM
How do I create an excel macro to append to a cell with existing i zola_tiara Excel Discussion (Misc queries) 4 September 14th 05 08:22 PM
Hotkey problem w/ macro to append comment roadkill Excel Discussion (Misc queries) 1 April 6th 05 06:52 PM


All times are GMT +1. The time now is 09:04 PM.

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"