VB to Find Rows

  • Thread starter Glenn Robertson
  • Start date
G

Glenn Robertson

Hi,

I have a spreadsheet with 4 sheets (Sheet 1,2,3 and
Total). I have written this code which will look at Sheet
1 and autofilter by the name I have entered in my Input
Box.

Dim Name1 As String
Name1 = InputBox("Please Enter Name: ", "name1")
Sheets("Sheet1").Select
Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:=Name1
End Sub

What I want is code that when I can put a name in my Input
Box. It will search Sheet1, Sheet2, Sheet3 and copy any
rows that have that name in to the totals sheet.
 
S

Simon Lloyd

Here is some code for find and delete duplicates, so you can modify i
so rather than delete it copies and pastes.....have a go see what yo
think!

Simon

Heres the code

Sub RemoveDuplicateCells()
Dim Myrange As Range
Dim C As Range
Dim DelRange As Range
Dim FindRange
Set Myrange = Intersect(ActiveSheet.UsedRange, Columns("D"))
If Myrange Is Nothing Then Exit Sub
Application.ScreenUpdating = False
FindRange = Array("D", "D", "D")
For Each elem In FindRange
Set C = Myrange.Find(elem, Myrange.Cells(1), xlValues, xlPart)
If Not C Is Nothing Then
If DelRange Is Nothing Then Set DelRange = Rows(C.Row)
firstaddress = C.Address
Do
Set C = Myrange.FindNext(C)
Set DelRange = Union(DelRange, Rows(C.Row))
Loop While firstaddress <> C.Address
End If
Next
Application.ScreenUpdating = True
If DelRange Is Nothing Then Exit Sub
DelRange.Delete shift:=xlUp
End Sub


Public Sub Delete_In_H()
Const MyColumn As Integer = 4
Dim lngRow As Integer
Dim maxRow As Integer

maxRow = Cells(ActiveSheet.Rows.Count, MyColumn).End(xlUp).Row

For lngRow = maxRow To 1 Step -1
If Cells(lngRow, MyColumn).Value = "D" Then

Cells(lngRow, 3).Delete
Cells(lngRow, 4).Delete
Cells(lngRow, 5).Delete
Cells(lngRow, 6).Delete
Cells(lngRow, 7).Delete

End If
Next lngRow
End Su
 
4

43fan

Simon,

I think this'll work great for the problem I'm having(there's a new post
above this thread about it). But, how would I go about copying just one
column from everywhere that it finds the argument?

IOW, I'm looking for an "X" in, say Column B. I want all values from Column
A that have an X in column B.

Thanks!
Shawn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Copy And Paste Rows 1
Search other sheets for numbers & color them 10
Macro1 2
Command Button to import worksheets 1
Help me4 2
filter 1
Creating named ranges.....Error 1
Selection.AutoFilter Issue 1

Top