473,654 Members | 3,096 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Search open files for string and then copy that row into a new workbook

2 New Member
Hello,
I am trying to develop a vb program for Excel which will search through open workbooks for a text string (let's say that string is "error" for example) in a cell. Once this program finds this string, I need it to copy that cell and adjacent cells into a different workbook (this will be used to summarize the errors). As it copies this information, it would be nice if it stepped down the page as it pasted (so all the error cells wouldn't be pasted on top of one another). I am pretty new to vb and have been searching the web for a similar post but have not found it. I really appreciate any help you can give!

Thanks,
nick
Mar 12 '08 #1
2 1390
jeffstl
432 Recognized Expert Contributor
Hello,
I am trying to develop a vb program for Excel which will search through open workbooks for a text string (let's say that string is "error" for example) in a cell. Once this program finds this string, I need it to copy that cell and adjacent cells into a different workbook (this will be used to summarize the errors). As it copies this information, it would be nice if it stepped down the page as it pasted (so all the error cells wouldn't be pasted on top of one another). I am pretty new to vb and have been searching the web for a similar post but have not found it. I really appreciate any help you can give!

Thanks,
nick
Are you creating a seperate .exe that will perform this job?...or are you developing the VB Code in Excel (VBA) ?

Pretty tall order....I don't think anyone will post the work for you so you will probably be better off getting started and getting down to the specific problems you run into.

I do have a huge VBA app written in excel that reads various cells and generates graphs, etc, but none of this is pretty and its all completely dependant on individual format\design of the actual spreadsheet your working with.
Try this I guess for now and see how you do:
http://www.excel-vba.com/excel-vba-contents.htm
Mar 12 '08 #2
taylordude
2 New Member
Ok here's what I have so far. It's an amalgamation of many snippets I've found online so far:

ub test()
Dim wbk As Workbook
Dim sht As Worksheet

For Each wbk In Workbooks
For I = 1 To Worksheets.Coun t
Dim LSearchRow As Integer
Dim LCopyToRow As Integer

On Error GoTo Err_Execute

'Start search in row 4
LSearchRow = 4

'Start copying data to row 2 in Sheet2 (row counter variable)
LCopyToRow = 2

While Len(Range("A" & CStr(LSearchRow )).Value) > 0

'If value in column E = "Mail Box", copy entire row to Sheet2
If Range("B" & CStr(LSearchRow )).Value = "Failed" Then

'Select row in Sheet1 to copy
Rows(CStr(LSear chRow) & ":" & CStr(LSearchRow )).Select
Selection.Copy

'Paste row into Sheet2 in next row
Workbooks("Proj Summary.xls").S heets("Sheet2") .Select
Rows(CStr(LCopy ToRow) & ":" & CStr(LCopyToRow )).Select
ActiveSheet.Pas te

'Move counter to next row
LCopyToRow = LCopyToRow + 1

'Go back to Sheet1 to continue searching
Sheets("Sheet1" ).Select

End If

LSearchRow = LSearchRow + 1

Wend

'Position on cell A3
Application.Cut CopyMode = False
Range("A3").Sel ect

MsgBox "All matching data has been copied."

Exit Sub

Err_Execute:
MsgBox "An error occurred."
Next
ActiveWorkbook. Close
Next wbk
End Sub


I am trying to thumb through all of the open workbooks looking for rows containing the word "Failed". Once found, I am trying to paste that row into a summary sheet (ProjSummary.xl s) and step down to the next row so that when "Failed" is found in another workbook, it won't past on top of the previously pasted row. I think this code is close, but I am getting some errors. Thanks for the help!
Mar 21 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

13
35524
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet and extract information from specific worksheets and cells. I'm not really sure how to get started with this process. I ran the COM Makepy utility from my PythonWin (IDE from ActiveSTate),
6
1866
by: E Pease | last post by:
I have been trying to edit the Explorer example by Dev Ashish I found on www.msvp.org (I think). I have been all over the net so I am not quite sure where the file came from. I like the way it works but I can not find a way to tell it to display a certain directory. I want it to display a folder on our share drive. I know the path for the directory. I want users to be able to open any files below the parent directory I tell it to start in....
5
2099
by: Jim | last post by:
Hello, I am working on a small windows application for a client, and as one of the functions they want a search that will let them enter a search string, then search a directory for all flies that contain that search string AND display the lines that contain the search string. They have windows ME, XP and 2000 systems. Does anyone have any ideas as to the most efficient way to do this?
3
7419
by: Jennyfer Barco | last post by:
Hello, I have a question, how can I open Microsoft Excel from .NET. I only need to open a new file in Excel and paste some information and set the Microsoft Excel as the enabled aplication, so the user can continue working in Excel and he'll save the information I pasted. I tried this but doesn't open Excel at all, but it does save the file c:\test.xls with the value "This is column B row 2" in colum B and row 2: Dim xlApp As...
1
2715
by: Eric | last post by:
Hi: I have two files. I search pattern ":" from emails text file and save email contents into a database. Another search pattern " field is blank. Please try again.", vbExclamation + vbOKOnly Me.txtEmail.SetFocus Exit Sub End If Me.txtStatusBar.Value = "Parsing..." strEmail = Me.txtEmail.Value
0
5088
by: mix01 | last post by:
Hi, I am trying to get some VBA code working, but am preplex as to why it does not work. I would really appreciate any level of help. Many thanks, Mix01 Version of the program
2
1966
by: princymg | last post by:
I want to search a file from server and want to copy it to the local disk. how it is done? This is working if the file is in my hard disk itself.But not when it comes to server. If i map the server i can search.like y:\\serverfolde\\folder am tring to make an exe. different people will map to different drive. so i cant give like that.should give like @\\server\\serverfolde\\folder\\ but it is not working. My code is<code>...
2
1677
by: princymg | last post by:
I want to search a file from server and want to copy it to the local disk. how it is done? This is working if the file is in my hard disk itself.But not when it comes to server. If i map the server i can search.like y:\\serverfolde\\folder am tring to make an exe. different people will map to different drive. so i cant give like that.should give like @\\server\\serverfolde\\folder\\ but it is not working. My code is...
4
4032
by: omono84 | last post by:
I know that this should be rather simple but i seem to be missing a step to get it to work. and have been unable to find a solution on the net. The aim is that I click on the open button to find and open an unknown workbook that contains the data that I need to imput into my current workbook, once the unknown workbook is opened it should automatically select my range (number of columns known, but number of rows unknown- the number of rows...
0
8376
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8489
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8594
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7307
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2716
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1596
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.