Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default help with code

I have a workbook with three worksheets.

sheet1
sheet2
sheet3


Can anyone help me create code to do the following.

Create a new worksheet and name it "Report"

Create a list unique records from column A:A in sheet1, sheet2, and sheets3
and put in Column A:A in the newly created worksheet ("Report"). The
worksheets may have duplicate records so I'm trying to create a list of
unique records from my three worksheets.

Thanks,

--
Regards,

timmulla
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default help with code

Sub ProcessData()
Dim LastRow As Long

Worksheets.Add
ActiveSheet.Name = "Report"
With Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("A1").Resize(LastRow).Copy ActiveSheet.Range("A1")
End With
With Worksheets("Sheet2")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("A1").Resize(LastRow).Copy
ActiveSheet.Range("A1").End(xlDown).Offset(1, 0)
End With
With Worksheets("Sheet3")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("A1").Resize(LastRow).Copy
ActiveSheet.Range("A1").End(xlDown).Offset(1, 0)
End With
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("B1").FormulaR1C1 = "=COUNTIF(R1C1:RC[-1],RC[-1])"
.Range("B1").AutoFill Destination:=Range("B1").Resize(LastRow)
.Rows(1).Insert
.Range("B1").Value = "temp"
.Range("B1").Resize(LastRow + 1).AutoFilter Field:=1,
Criteria1:="1", Operator:=xlAnd
.Range("B1").Resize(LastRow +
1).SpecialCells(xlCellTypeVisible).EntireRow.Delet e
End With
End Sub


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"timmulla" wrote in message
...
I have a workbook with three worksheets.

sheet1
sheet2
sheet3


Can anyone help me create code to do the following.

Create a new worksheet and name it "Report"

Create a list unique records from column A:A in sheet1, sheet2, and
sheets3
and put in Column A:A in the newly created worksheet ("Report"). The
worksheets may have duplicate records so I'm trying to create a list of
unique records from my three worksheets.

Thanks,

--
Regards,

timmulla



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default help with code


Sub findunique()

Worksheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Name = "Report"

NewRow = 1
For Each sht In ThisWorkbook.Sheets
If sht.Name < "Report" Then

LastRow = sht.Cells(Rows.Count, "A").End(xlUp).Row
For RowCount = 1 To LastRow
If sht.Range("A" & RowCount) < "" Then
data = sht.Range("A" & RowCount)
With Sheets("Report")
Set c = .Columns("A:A").Find(what:=data, _
LookIn:=xlValues)
If c Is Nothing Then
.Range("A" & NewRow) = data
NewRow = NewRow + 1
End If
End With
End If
Next RowCount
End If
Next sht


End Sub
"timmulla" wrote:

I have a workbook with three worksheets.

sheet1
sheet2
sheet3


Can anyone help me create code to do the following.

Create a new worksheet and name it "Report"

Create a list unique records from column A:A in sheet1, sheet2, and sheets3
and put in Column A:A in the newly created worksheet ("Report"). The
worksheets may have duplicate records so I'm trying to create a list of
unique records from my three worksheets.

Thanks,

--
Regards,

timmulla

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default help with code

Sub Macro1()
Sheets.Add
ActiveSheet.Name = "Report"
For i = 1 To 3
Sheets("sheet" & i).Activate
Set r = Range("A1")
Range(r, r.End(xlDown)).Copy
Sheets("Report").Activate
n = Cells(Rows.Count, "A").End(xlUp).Row + 1
Range("A" & n).Select
ActiveSheet.Paste
Next
MsgBox (" ")
Set r = Range("A:A")
For j = Cells(Rows.Count, "A").End(xlUp).Row To 1 Step -1
v = Cells(j, "A").Value
k = Application.WorksheetFunction.CountIf(r, v)
If k 1 Then
Cells(j, "A").EntireRow.Delete
End If
Next
End Sub
--
Gary''s Student - gsnu200759
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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. Corey Excel Programming 3 December 11th 06 05:14 AM
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... Corey Excel Programming 4 November 25th 06 04:57 AM
Modification in the CODE to HIDE rows and columns that start with ZERO (code given) Thulasiram[_2_] Excel Programming 4 September 26th 06 04:15 AM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM


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

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"