Question : Visual Basic Code - Excel - Merge multiple worksheets in an excel workbook into single worksheet

Hello experts,

I am looking for a way in Visual Basic to merge data in multiple worksheets in an excel file into a single worksheet . Is there a way to achieve this?

e.g:


Sheet 1
_______


    A  |  B  |  C  |  D  | E  |  F  |  G | H |

1  a1   b1  c1  d1  e1  f1  g1  h1

2  a2   b2  c2  d2  e2  f2  g2  h2

3  a3   b3  c3  d3  e3  f3  g3  h3

4  a4   b4  c4  d4  e4  f4  g4  h4

5  a5   b5  c5  d5  e5  f5  g5  h5


Sheet 2
_______


    A | B | C |  

1  x1   y1  z1  

2  x2   y2  z2  

3  x3   y3  z3  

4  x4   y4  z4    

5  x5   y5  z5  



Sheet 3   (Merged Sheet)
_______


    A |  B |  C |  D |  E |  F |  G |  H |  I |  J |  K |

1  a1   b1  c1  d1  e1  f1  g1  h1  x1  y1  z1

2  a2   b2  c2  d2  e2  f2  g2  h2  x2  y2  z2

3  a3   b3  c3  d3  e3  f3  g3  h3  x3  y3  z3

4  a4   b4  c4  d4  e4  f4  g4  h4  x4  y4  z4

5  a5   b5  c5  d5  e5  f5  g5  h5  x5  y5  z5

Answer : Visual Basic Code - Excel - Merge multiple worksheets in an excel workbook into single worksheet

In its simplest form, just this

Dave

1:
2:
3:
4:
5:
Sub MergeEm()
Sheets(3).Cells.ClearContents
Sheets(1).UsedRange.Copy Sheets(3).[a1]
Sheets(2).UsedRange.Copy Sheets(3).Cells(1, Columns.Count).End(xlToLeft).Offset(0, 1)
End Sub
Random Solutions  
 
programming4us programming4us