Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Concatenate and copy in VBA


I am writing a macro to transfer data from one worksheet to another
Unfortunately, the data is in different columns which makes things mor
awkward and because not all data is to be included the macro includes
routine to find the lines of data to be transposed and then finds th
next blank line on the other sheet into which it is to be transposed.

My particular problem is that there are 4 adjacent cells of data in th
same row in the first sheet which have to be concatenated into one cel
in the second.

I am using a FOR ...NEXT loop to control the movement, so it is eas
enough to find the correct row by the following method, e.g.

ActiveCell.Offset(rowOffset:=N, columnOffset:=0).Activate

How can I select all 4 cells and concatenate them, then paste them ont
the other worksheet?

I can't change the format of the two worksheets.

Thanks,

Andyg

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Concatenate and copy in VBA

one way:

Dim sConCat As String
Dim i As Long
With ActiveCell
For i = 0 to 3
sConCat = sConCat & .Offset(0, i)
Next i
End with
Workbooks("Book2.xls").Sheets("Sheet1").Range("J1" ).Value = sConCat

in general, you should try to address ranges directly rather than
through Select/Activate. Doing so makes your code smaller, faster, and
IMO, easier to maintain.

In article ,
ANDYGM wrote:

I am writing a macro to transfer data from one worksheet to another.
Unfortunately, the data is in different columns which makes things more
awkward and because not all data is to be included the macro includes a
routine to find the lines of data to be transposed and then finds the
next blank line on the other sheet into which it is to be transposed.

My particular problem is that there are 4 adjacent cells of data in the
same row in the first sheet which have to be concatenated into one cell
in the second.

I am using a FOR ...NEXT loop to control the movement, so it is easy
enough to find the correct row by the following method, e.g.

ActiveCell.Offset(rowOffset:=N, columnOffset:=0).Activate

How can I select all 4 cells and concatenate them, then paste them onto
the other worksheet?

I can't change the format of the two worksheets.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Concatenate and copy in VBA

Excellent!

That works very well,

Thanks

--
Message posted from http://www.ExcelForum.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
Formula: copy/concatenate cell contents matching condition Neil Hutchinson Excel Discussion (Misc queries) 4 September 2nd 08 09:51 AM
Copy Concatenate Cathie[_2_] Excel Discussion (Misc queries) 1 August 27th 08 02:25 PM
EXCEL FILE a copy/a copy/a copy ....filename ve New Users to Excel 1 September 29th 05 09:12 PM
I know how to concatenate ,can one de-concatenate to split date? QUICK BOOKS PROBLEM- New Users to Excel 1 July 26th 05 05:07 PM
COPY A CONCATENATE CELL TO BLANK CELL PUTTING IN THE NEXT BLANK C. QUEST41067 Excel Discussion (Misc queries) 1 January 15th 05 09:29 PM


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