Use VBA To Search Worksheets - If Value Is Found Copy Only Those Sheets Into New Workbook

Dec 5, 2013

I found some useful code for copying specific worksheets into a new workbook based on the sheet name, which I have not been able to alter to suit my needs.

I have a workbook that has a Master Sheet that contains a summary of each claim (Name, type of claim, dates, dollar amounts, etc.) and a sheet for each specific claim.

I know I can use the filter feature on the master sheet to view all of the physical damage claims (and one column has a hyperlink to the worksheet for that specific claim). But every month I have to create a report that shows each type of claim, dates, and so on.

I would like to create a macro that can copy the worksheets to a new workbook based on the type of claim it is. I'm thinking something like for each ws in wb if range ("F15") = 1 & .range ("B4") < 30 days from today copy that sheet into a new wb.

Below is a generic and far smaller version of my workbook. The name column contains my hyperlinks to the specific sheet. Each sheet is also named based on the text in the name column (so John Doe's sheet would be named 'John Doe') and so forth.

Date of Loss
Name
Cargo
BI
PD
Paid
Reserves

[Code] ........

View 1 Replies


ADVERTISEMENT

Search All Worksheets & Go To Found Values

Aug 30, 2007

I have a workbook with a sheet for every month. I have a searchbox searching for a client and jumping to that location. The problem I am having is that it takes me to the last occurence in the workbook if there is more that one client with the search criteria. Do you have any suggestions for a searchbox that whould take me to the first occurence and give me an option to go to the next occurence in the workbook. Please see the code below that I am using currently using.

Private Sub CommandButton1_Click()
Dim ws As Worksheet

Dim cl As Range, rng As Range
For Each ws In ActiveWorkbook.Worksheets

Set rng = ws.UsedRange
With rng
Set cl = .Find(Me.TextBox1.Value, LookIn:=xlValues)

If Not cl Is Nothing Then

Application.Goto cl

Else

View 7 Replies View Related

Search 1 Column All Worksheets & Go To Found Values

Aug 28, 2007

I need a VBA script that can display a search box on multiple sheets within the same workbook similar to using ctrl + F and search values in column B only. If there is text or the row happens to be empty then it should skip that and only search numbers. Also the numbers in column B range from 50000 to 89000 and if there is a wrong number entered then I want to have a pop up box saying Error: invalid value or something like that.

Sub search_box()
Range("B49000").Select
Cells.Find(What:="some#", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
Cells.FindNext(After:=ActiveCell).Activate
End Sub

View 8 Replies View Related

Copy Template Worksheet To Multiple Worksheets And Incrementally Number Sheets In Workbook

Mar 25, 2014

I have what is probably a simple request to all the VBA experts out there, and simply want to take a template sheet in a workbook and copy it across to 100 sheets numbered/named 101 -200, and add the name of each sheet as a text reference, e.g. sheet name 101 will have a cell within the worksheet that refers to sheet 101.

I have attached a simplified spreadsheet which indicates what i'm trying to achieve.

View 7 Replies View Related

Excel 2007 :: Search Worksheets And Delete Entire Row When Duplicates Found?

Jul 17, 2013

I have a excel 2007 workbook that has 5 sheets "MASTER" , "RED" , "WHITE", "GOLD" & "BLUE". There are 7 columns in each sheet and the master has about 8,000 rows . In column D of each sheet there is a unique number (approx. 8 - 10 digits ) that I would like to at the press of a command button search through sheets "RED" "WHITE" "GOLD" & "BLUE" against the unique numbers in the "MASTER" sheet and if there any duplicates numbers delete the entire row but leave all the data in the master sheet.

View 2 Replies View Related

Search Sheets For Value & Return Sheet Number When Found

Feb 16, 2008

i have a workbook with several sheets in it. i would like to make a userform were i could put a number in a text box eg E045698.then use a command button to search all the worksheets for that number and display the sheet number where that number is in another textbox.

View 5 Replies View Related

Search Workbook & Format Found Results

Oct 18, 2007

I was looking at this VBA code the other day and i was wandering what i meant. I thought if somone could expliane line by line,

Sub CommandButton1_Click()

Dim ThisAddress$, Found, FirstAddress
Dim Lost$, N&, NextSheet&
Dim CurrentArea As Range, SelectedRegion As Range
Dim Reply As VbMsgBoxResult
Dim FirstSheet As Worksheet
Dim Ws As Worksheet
Dim Wks As Worksheet
Dim Sht As Worksheet

View 6 Replies View Related

How To Create Search Macro Button That Allows To Search In Multiple Worksheets In One Workbook

Oct 11, 2011

Im am trying to create a search marco button that allows me to search in multiple worksheets in one work book. I came across this CODE the first part of it works. It pops open user input box and ask for the word that i would like to search but the this error message pops up Runtime error1004 Method 'range" of object'_Global'failed and i dont know what to do

Private Sub SearchButton_Click()
SearchString = InputBox("Enter Search String", "Search")
If SearchString = "" Then Exit Sub
For Each c In Range(myRange)
If InStr(LCase(CStr(c)), LCase(SearchString)) Then

[Code]....

View 1 Replies View Related

Search Function (locate Data) Search All Sheets Within The Workbook

Sep 14, 2009

Using the search macro code below, could someone please help to add in more codes what I'm currently using, and also where to insert it. The Search function works well for what I need and it helps me to locate data. When using the search function somehow it search all sheets within the workbook but I only want it to search an array of sheets when using this macro that is needed to complete the task for what I'm after.

Macro
Public Sub FindText()
'Run from standard module, like: Module1.

Dim ws As Worksheet, Found As Range, rngNm As String
Dim myText As String, FirstAddress As String, thisLoc As String
Dim AddressStr As String, foundNum As Integer

myText = InputBox("Enter the text that you want to search for:", "Start Search!")

If myText = "" Then Exit Sub...................

View 9 Replies View Related

Excel 2010 :: Search Column For Match If Found Copy Cell To Next Vacant Row

Jul 8, 2014

I have a file which has in excess of 12,000 rows of data in 5 columns (sample file attached with fake data). The five rows are:

"First Name" "Last Name" "Name" (uses CONCATENATE to combine column A & B) "Email" "Date Attended"

There will be duplications in the list as people will have attended more than once over the years.
What I want to do is search through the email addresses (Column D with D1 being the header) and where there is a duplicate email address copy the cell to the right of the duplicate (F#) into the next available cell to the right of the first occurance and then delete the row with the duplicated email address.

I am on Windows 7 and Excel 2010

View 4 Replies View Related

If Text Is Found On Two Sheets, Copy Entire Row

Jun 9, 2009

I have one master worksheet with 1000 ID's. I also have 10 other spreadsheets with 1000 ID's. I need my macro to use the master worksheet and identify where the IDs are located among the 10 spreadsheets. If there is a match, then my macro should copy the entire row and place it in an output file (another spreadsheet).

The following code only tests the master worksheet and three other sheets (one being null/error is ID not found).

Sub Macro5()
'
' Macro5 Macro
Dim Raw, Mix1, Mix2, error As Excel.Worksheet
Set Raw = Sheets("RAW_DATA")
Set Mix1 = Sheets("Mix1")
Set Mix2 = Sheets("Mix2")
Set error = Sheets("error")
Raw.Select
For x = 1 To 1000
For y = 1 To 1000
If Raw.Cells(x, 1) = Mix1.Cells(y, 1) Then.................

View 9 Replies View Related

Search A Workbook With Multiple Worksheets

Mar 28, 2008

Need MACRO to search a workbook with multiple worksheets?

View 9 Replies View Related

Search ALL The Sheets In One Go On A Workbook

May 11, 2006

way of being able to search ALL the sheets in one go on a workbook? Going through all the sheets maybe one by one, i cant fathem it at all.

View 9 Replies View Related

Search Cell Value In Another Workbook And Copy Range From Current To Other Workbook

Mar 11, 2014

I have 2 workbooks. 1 is where data is entered called wksPB, the other is like a database workbook. The wksPB has data to be feed from column B to F and there is a dropdown.

what im looking to do is, if the combobox value is selected as Decline then it should display a messagebox that reference value in cell B is denied. if combobox value is Agreed then the macro should search the database workbook for the text entered in column b of wksPB and then copy data of C:E of wksPB to H:J of database sheet where that text is found and also the approver name in wksPB C24 to the approver cell of where that text was found. I've reached till finding the text but what I get my head twiting on is how to copy the text from wksPB column B:F to database sheet column H:K. Im attaching the sample workbooks and the code where ive reached till.

[Code] .....

Attached Files
Replacement Records - 2014.xlsx‎
forum file.xlsm‎

View 1 Replies View Related

Method To Search Other Sheets In Workbook For Unique Row

Mar 26, 2013

My workbook contains a input sheet and multiple sheets with the data I compile. In the examples I provided, on each sheet "Server Name" is unique data to each sheet. I would like to have the ability on the Input sheet to click one of the server names and that take the user to the record on sheet 2. Not sure iif I need to be looking at a Macro or a formula to do this.

View 1 Replies View Related

Search Copy And Paste Across Multiple Worksheets?

Oct 12, 2011

I have a workbook with 6 worksheets in, 5 worksheets contain data whilst the 6th I will use as a search worksheet. The 5 data worksheets contain columns A to J which have text entries in.

What I would like to click a button on the search worksheet, lets call it worksheet 1, and for an inputbox to allow the user to enter a text search. The macro would then search for this text in columns A to J and all rows (or rows with data in) on the 5 data worksheets, and if found, copy the entire contents of those rows where the text is found and paste them into worksheet 1, the search sheet.

I have done a forum search and found a few examples of this type of search but not across multiple worksheets, also I found this code that does search across multiple sheets but does not copy and paste:

VB:
Sub Find_Data()
Dim datatoFind
Dim sheetCount As Integer
Dim counter As Integer

[Code]....

View 5 Replies View Related

Data Search & Copy From Mulitple Worksheets

Dec 31, 2009

I have a workbook with 26 multiple worksheets that each represent 1 of 26 payperiods per year (bi-weekly payperiods). These worksheets consists of rows of employees names and hours worked each day. The columns consist of dates representing each day in that payperiod.

I need to be able to search all the worksheets (ie. search all 26 payperiods) to find specific 30 day intervals and then copy each employees hours worked to a master spreadsheet. I have tried variations of Index & Match formulae as well as vlookup/hlookup/ISNA without luck. I am not able to use VBA.

View 5 Replies View Related

Macro - Search Sheets In Same Workbook And Highlight Data

Jun 20, 2014

I have a worksheet with multiple sheets.

Users and Data

In users column A has email contacts from people that accessed a recoding on line. I need to be able to cross reference with another sheet called data where I will have their full name.

Basically I would like a macro that will check column A in users sheet and check in data the name column . If it finds last name or partial name in the mail it will highlight it in the users sheet and in the name column in data

User sheet
Column A is raw 1 is heading username

data sheet
column B is raw 1 Last Name

That way I am able to quickly identify a group of people if they did not watch the recording as user gives me indication on what they did.

View 5 Replies View Related

Search And Copy Cells Across Sheets

Jul 11, 2013

Copying cells. It is across 2 sheets.

The cells I want to fill are in column V in sheet 2. ie v10, v11, v12, etc.

On sheet 2 column d contains an item count and V is the count of that item.

Then on sheet 1 column ranges (B4 To B49) (G4 To G49) (L4 To L49) (Q4 To Q49) contains the relevant item code to column D on sheet 2. Also on sheet one the count section that I want copied into V on sheet 2 which is columns D,I, N,S 4-49 etc..

My issue is that sheet 1 is constantly rearranging and sheet 2 is in numerical order of column D.

So how do I get sheet 2 V10 to populate by searching for the item code of D10 on sheet 2 in B,G,L,Q of sheet 1 then once located to then copy the contents of the number from D,I,N,S that works with the item list?

Then once done this that I can copy the formula all the way down column V in sheet 2?

View 5 Replies View Related

Automatic Search/Copy/Paste Between Sheets, How?

Mar 13, 2009

I would like Excel to do the following and have no idea how to write the instructions. The function is as follows:

From a general information sheet (sheet #1), XCEL looks at a cell to determine if that cell holds "A" or "B" (will be a word, and choice will be previously fixed by a dropdown menu). It then looks at another cell in the same row to determine if it equals 0 or 1.
If the cell holds A, and the other cell holds 0, XCEL copies the row from the general information sheet onto sheet #2 of the same workbook.

If the cell holds B and the other cell holds 0, XCEL copies the row from the general information sheet onto sheet #3 of the same workbook.

After XCEL has copied a row, it inputs a 1 in a final cell of that row so it will not copy that row again.

On sheet #2 and sheet #3, XCEL begins (and copies to) the first open row in column A (by moving there after performing its last copy function or by checking column A until it finds a cell = 0), so that each new copy function begins in an open row.

View 12 Replies View Related

Search In Two Sheets, Then Copy Matches To 3rd Sheet

Sep 22, 2009

I have a Excel file with alot of data in it. I need a macro that will create a report for me and relive me from alot of manual work. The 1st sheet is named "Projects". This contains the search arguments. The 2nd sheet is named "Database". This is the sheet where I want to search in. The 3rd sheet is named "Report". This will contain the results of the search. So the going will be something like this:

Copy row 7 from "Projects" into row 7 in "Report". Then use the value in that row, column E (named Search code). Search for rows that has this value in column E in the "Database" sheet. Copy all those rows to "Report" sheet. Copy row 8 from "Projects", leave two rows of space and paste into "Report". Repeat the procedure mentioned above. Repeat this until reaching a row in "Projects" that has no value in Column A.

View 5 Replies View Related

Copy Data From Multiple Sheets In Workbook To Different Workbook But On One Worksheet

Feb 7, 2014

I am looking for a code that would copy the data from each worksheet in a given workbook and then paste to just one worksheet within a different workbook. The Sheet names are auto generated when I run this canned report but the naming structure is always the same...the first worksheet is named Repair Details and then the next sheet is named Repair Details_1, the next sheet is named Repair Details_2 and so on for every sheet in workbook. So I would like to copy all of the data(Headers to last cell) and then paste in a worksheet(ex: Master Repair Report.xlsx and the worksheet could be titled Master Repair Details) on a different workbook, then the next sheet would copy from the one under the header to the last record and paste to the same workbook. This process would repeat for every worksheet in the Repair Details Workbook and paste to Master Repair Details worksheet in the Master Repair Report workbook.

View 4 Replies View Related

Copy Worksheets From Active Workbook To A New Workbook

Apr 22, 2009

I am trying to code a Macro so that i can take all the worsheets and save them as individual Workbooks. I wrote a macro that appeared to work, but, after it saves the first sheet as a workbook, i get a debug error.

MS VB Script error:
Runtime error '9':
Subscript out of range

Any advise would be greatly appreciated.

Thank you

Code is below..

Sub saveall()
'
'
For Each ws In ActiveWorkbook.Worksheets

ThisFN = "C:Documents and SettingsUserDesktop" & ws.Name & ".xls"
I = I + 1
Sheets(I).Select
Sheets(I).Move
ActiveWorkbook.SaveAs Filename:= _
ThisFN, FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False

Next ws

End Sub

View 9 Replies View Related

Search Multiple Sheets And Copy Results To New Sheet?

Jun 13, 2014

I have a workbook with 50+ sheets. Within each sheet are rows of data in column A that I'd like to search for specific text.

I'd like to search each row from every sheet for specific words (e.g. "7 days" AND "Monday" AND "Tuesday" etc.) then copy the entire row containing all my search text in a new sheet on column A along with the name of the sheet it was found in in column B and the row number it came from in column C.

What I am trying to accomplish is to search through all the sheets and post results in new sheets for each search string.

View 14 Replies View Related

Copy Worksheets To New Workbook

May 21, 2008

I have a workbook containing several worksheets I want to copy to a workbook of their own and save under a specific name/password through a macro.

However, I have five difficulties:

1) I want to new workbook to contain only 1 worksheet. So, only the worksheet copied from the original workbook, and no other worksheets.

2) I want to be able to manually select the destination file for the copied workbook, however. This should be the same file for all workbooks.

3) I want the data copied from original worksheet to be ‘pasted as value’ only, so no formulas in the new workbook.

4) I want the new workbook to be read-only. Therefore I want the workbook to be /locked and password protected. So, the password should be only for altering cells, not for opening the workbook. See also point below.

5) Regarding the naming and passwording part I have made a matrix table in a worksheet named: “Rekeningen” (this worksheet is in the original workbook). This table contains three columns:

Column A, cells 40:65, contains the names of the worksheets I want to copy
Column B, cells 40:65, contains the names of the new workbooks
Column C, cells 40:65, contains the passwords of the new workbooks

So for example ....

View 9 Replies View Related

Copy All WorkSheets To Another Workbook

Sep 5, 2007

Assume 2 Workbooks - the Active one and "Book2".

I mannaged to copy ALL the sheets from the ActiveWorkBook to "Book2" with the following code - but as you can see the code copies each of them AFTER the last sheet in "Book2".

Sub Copy_Sheets()
' Copy All sheets from ActiveWorkbook to "Book2.xls"
For Each SH In ActiveWorkbook.Sheets
SH.Copy After:=Workbooks("Book2").Sheets(Workbooks("Book2").Sheets.Count)
Next
End Sub

How can I copy them to "BEFORE", lets say Sheet(1) in "Book2" ?

I tried to change the SH.Copy command to somthing that sounds logic to me, such as:

SH.Copy Before:=Workbooks("Book2.xls").Sheets(1)

but got the: "Run-time error '9' - Subscript out of range".

View 5 Replies View Related

Search, Copy And Paste Entire Row Into New Workbook

Feb 22, 2010

I need a code that will search column A over multiple sheets for a user specified value through an input box. I then need this code to copy and paste the entire row to a new workbook titled "Batch Report" Anyone have any ideas? I have a code that will copy and paste only a few rows but no where near all of them, and I cant figure out why.

View 10 Replies View Related

Copy Active Worksheets Into One New Workbook

Jul 3, 2007

I have 16 proposals that are either hidden or visible in a proposal generator. I need to be able to copy only the visible worksheets over to a new workbook that uses a name from a cell inside the proposal generator. Then a save as prompt to force the user to save the file wherever they choose.

View 14 Replies View Related

Copy All Worksheets Into Master Workbook

Sep 19, 2009

Using a Command button into my Master file, I'm looking for a code that give me an option to select an existing file that will have a variable name & path, open it and then copy all worksheets contained within it, into my Master workbook. Then close the selected file on completion.

Not sure if it's important but some of the copied worksheet names will contain copies. e.g. Apples, Apples (2), Pears, Pears (2). etc.

View 9 Replies View Related

Copy Worksheets Into Current Workbook

Oct 30, 2006

I have developed a macro, run by a button click, in my workbook.

I have about 5 other workbooks to process, what I want to do is to have my workbook with my macro open, then either copy or import these other 5 workbooks, one at a time, into my current workbook so I can run my macro on their data. Not sure if I need to copy them in or not, but thats all I can think of. I'm not even sure how to do this manually, I tried having my workbook open and doing a file - import on the .xls file, but it seems to be translating my data and I'm ending up with a value of 'f1' in one of my columns, no idea what that is. All I really want to accomplish is to run my macro on each of the 5 workbooks, one at a time.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved