ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy cells from two worksheets into one (https://www.excelbanter.com/excel-programming/389611-copy-cells-two-worksheets-into-one.html)

Daniell

Copy cells from two worksheets into one
 
What I have is workbook that has two worksheets with one cell that could be
the same in both worksheets. If that cell has the same information in both
worksheets I would like to create a third worksheet and copy the information
from both of the other two worksheets into the new one.

David Sisson[_3_]

Copy cells from two worksheets into one
 
Sub FindTwoThenAddOne()

Dim Rng As Range
Dim Rng2 As Range
Dim Ws3 As Worksheet

Set Rng = ActiveWorkbook.Worksheets(1).Range("A1")
Set Rng2 = ActiveWorkbook.Worksheets(2).Range("A1")

If Rng = Rng2 Then
Set Ws3 = Worksheets.Add(after:=Worksheets(Worksheets.Count) )
Ws3.Range("A1") = Rng
End If

End Sub


Daniell

Copy cells from two worksheets into one
 
Thanks I will give it a try.

"David Sisson" wrote:

Sub FindTwoThenAddOne()

Dim Rng As Range
Dim Rng2 As Range
Dim Ws3 As Worksheet

Set Rng = ActiveWorkbook.Worksheets(1).Range("A1")
Set Rng2 = ActiveWorkbook.Worksheets(2).Range("A1")

If Rng = Rng2 Then
Set Ws3 = Worksheets.Add(after:=Worksheets(Worksheets.Count) )
Ws3.Range("A1") = Rng
End If

End Sub




All times are GMT +1. The time now is 06:12 AM.

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