Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

visual basic code to find particular word in excel sheet

Status
Not open for further replies.

nubees

Programmer
Aug 6, 2003
39
US
Hi all,
Please help me with a visualbasic sample code snippet or a tutorial where I can find how to do this.

1.I have a word called IssuedServer(s) in row number 6 and column number 1. I have to search for that word.
2. Once I find it, I have to copy the entire row following the row that has IssuedServer(s) word to another worksheet.

the row number and column numbers are never the same they keep changing from worksheet to worksheet.

I can provide you with more information if needed.
Any help would be greatly appreciated.

 
Maybe try:

xlAPP.Cells.Find(What:="search string", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) .Activate


-----
The death of dogma is the birth of reason.
 
can you tell me the next part ie how to copy the entire row following?


 
Something like this:

With xlAPP
.Cells.Find(What:="aaaa", After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Activate
.Rows("9:9").Select
.Selection.Copy
.Sheets(1).select
.Range("A12").Select
.ActiveSheet.Paste
End With

A really good way to learn is to record a macro in Excel, doing the keystrokes yourself, then go to the Excel editor, and copy and paste what you need.

I learned a lot that way.

Good luck. You'll figure it out.

-----
The death of dogma is the birth of reason.
 
I dont think I can use that code in my program.because, my program should be capable of running different excel sheets with different formats.
In all sheets the word IssuedServer(s) will be present but the row number where that is present keeps on changing, For example in one sheet the IssuedServerr(s) word may be in row number 10 and the row I should need to copy will be 11. And in someother sheet IssuedServer(s) word may be in row number 30 and the row I should copy will be in 31. So I cannot use the code generated by macro. Is there any other way I can do it?

thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top