ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need help in merging cells together (https://www.excelbanter.com/excel-programming/430190-need-help-merging-cells-together.html)

Neecy

Need help in merging cells together
 

I need a script to use in order to merge 4 different cells together that are
not listed next to each other on the same worksheet. My objective is to
create a unique identifier with the merging of these 4 cells together to
match up against another cell on another workbook. I haven't done much in
merging using VBA and have a script listed below for someone to review and
provide feedback as to where I am going wrong:

Sub Import()
Dim shtSup1 As Worksheet
Dim field1 As Range, field2 As Range, field3 As Range, field4 As Range,
Rng As Range, rngPaste As Range
Set field1 = Range("F44:F53")
Set field2 = Range("H44:H53")
Set field3 = Range("D44:D53")
Set field4 = Range("B44:B53")
Set rngPaste = Range("S44:S53")
Set Rng = Union(field1, field2, field3, field4)
Rng.Copy Destination:=rngPaste
End Sub

So far, I have joined these cells together, however, I need for them to be
merged together instead of unioned and the results to pasted in the fields
S44:S53.
Thanks-
Neecy


Don Guillett

Need help in merging cells together
 

Modify this simple idea to suit

Sub importSAS()
Range("a2:b2,a6:b6").Copy Range("e9")
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Neecy" wrote in message
...
I need a script to use in order to merge 4 different cells together that
are
not listed next to each other on the same worksheet. My objective is to
create a unique identifier with the merging of these 4 cells together to
match up against another cell on another workbook. I haven't done much in
merging using VBA and have a script listed below for someone to review and
provide feedback as to where I am going wrong:

Sub Import()
Dim shtSup1 As Worksheet
Dim field1 As Range, field2 As Range, field3 As Range, field4 As Range,
Rng As Range, rngPaste As Range
Set field1 = Range("F44:F53")
Set field2 = Range("H44:H53")
Set field3 = Range("D44:D53")
Set field4 = Range("B44:B53")
Set rngPaste = Range("S44:S53")
Set Rng = Union(field1, field2, field3, field4)
Rng.Copy Destination:=rngPaste
End Sub

So far, I have joined these cells together, however, I need for them to be
merged together instead of unioned and the results to pasted in the fields
S44:S53.
Thanks-
Neecy



Neecy

Need help in merging cells together
 

Hi Don-

Thanks for replying. I need for the columns to merge together instead of
copying to another field. Do you have an script for merging I can modify to
suit based on my objectives listed below?

Thanks-
Neecy

"Don Guillett" wrote:

Modify this simple idea to suit

Sub importSAS()
Range("a2:b2,a6:b6").Copy Range("e9")
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Neecy" wrote in message
...
I need a script to use in order to merge 4 different cells together that
are
not listed next to each other on the same worksheet. My objective is to
create a unique identifier with the merging of these 4 cells together to
match up against another cell on another workbook. I haven't done much in
merging using VBA and have a script listed below for someone to review and
provide feedback as to where I am going wrong:

Sub Import()
Dim shtSup1 As Worksheet
Dim field1 As Range, field2 As Range, field3 As Range, field4 As Range,
Rng As Range, rngPaste As Range
Set field1 = Range("F44:F53")
Set field2 = Range("H44:H53")
Set field3 = Range("D44:D53")
Set field4 = Range("B44:B53")
Set rngPaste = Range("S44:S53")
Set Rng = Union(field1, field2, field3, field4)
Rng.Copy Destination:=rngPaste
End Sub

So far, I have joined these cells together, however, I need for them to be
merged together instead of unioned and the results to pasted in the fields
S44:S53.
Thanks-
Neecy





All times are GMT +1. The time now is 07:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com