copying to main sheet

chris1234567

New Member
Joined
Sep 21, 2006
Messages
12
I have a spreadsheet with 8 tabs accross the bottom

the first is called staff
the next six tabs are labelled a,b,c,d,e,f

What I require is when the number is column B on all 6 sheets starts with a T for example: T9777 would fit the criteria it will copy that whole row and place it on the next avaiable row on the first tab "staff".

I need it too look through all the B colums on all six sheets.

Can this be done without invloving VBA
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
I assume thet there is no other previous data in sheet staff.

now run the macro given below. see the comments inthe codes.
Code:
Sub TEST()
Worksheets("staff").Cells.Clear
'the above line is to celar the sheet staff so that
'you can test the macro once or twice
'this assumes there is no other data in "staff"

Dim x, add As String
Dim dest, cfind As Range
x = "T"
Dim sh As Worksheet
For Each sh In ThisWorkbook.Worksheets
sh.Activate
If sh.Name = "staff" Then GoTo line1
Set cfind = Cells.Find(what:="T")
If Not cfind Is Nothing Then
If cfind.Column <> 2 Then GoTo line2
add = cfind.Address
Set dest = Worksheets("staff").Cells(Rows.Count, "b").End(xlUp).Offset(1, 0)
'MsgBox dest.Address
cfind.EntireRow.Copy dest.Offset(0, -1)
line2:
End If
Do
Set cfind = Cells.FindNext(after:=cfind)
If cfind.Column <> 2 Then GoTo line3
Set dest = Worksheets("staff").Cells(Rows.Count, "b").End(xlUp).Offset(1, 0)
'MsgBox dest.Address

cfind.EntireRow.Copy dest.Offset(0, -1)
line3:
Loop While Not cfind Is Nothing And cfind.Address <> add
line1:
Next sh
Worksheets("staff").Activate
MsgBox "macro is over"
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top