| | |
Problem searching multiple sheets in excel
![]() |
Below I have listed my code. I am having a problem searching through multiple sheets in an excel workbook. As of now, it will load cboPcMark with only the first page of search results. It will also duplicate a couple of them. Can someone please take a look. Thanks in advance.:eek:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
cboPcMark.Clear Dim objExcel As Object ' Excel application Dim objBook As Object ' Excel workbook Dim objSheet As Object ' Excel Worksheet Dim ExcelCutlist As String Dim rng As Range Dim firstAddress As String Dim PcMark As String 'Dim objSheet As Excel.Sheets ExcelCutlist = App.Path & "\" & "TANA EC 271 I.xls" Set objExcel = CreateObject("excel.application") Set objBook = objExcel.Workbooks.Open(ExcelCutlist) 'Set objSheet = objBook.Worksheets.Item(1) objExcel.Application.Visible = True For Each objSheet In objBook.Worksheets Set rng = Nothing With objSheet.Cells Set rng = objSheet.Range("D:E").Find(What:=txtHeat.Text, lookin:=xlValues, LookAt _ :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _ False) If Not rng Is Nothing Then firstAddress = rng.Address Do cboPcMark.AddItem Range(rng.Address).Offset(0, -4) Set rng = objSheet.FindNext(rng) Loop While Not rng Is Nothing And rng.Address <> firstAddress End If End With Next objSheet Set objSheet = Nothing If Not objBook Is Nothing Then objBook.Close Set objBook = Nothing objExcel.Quit Set objExcel = Nothing
James Davis
![]() |
Similar Threads
- Anchoring problem in Firefox, it crops my browser after clicking the link (HTML and CSS)
- SAS datasets to Excel multiple sheets (Computer Science)
- Extract MS Excel Data embedded in MS Word (Visual Basic 4 / 5 / 6)
- Internet Explorer multiple windows problem - XP (Web Browsers)
- Problem with XIRR calculation with ASP and EXCEL (ASP)
- problem in passing multiple checkbox values (ASP)
- searching multiple fields (PHP)
- Computer will not display red (Windows 95 / 98 / Me)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Take long time to open
- Next Thread: IsNull using VB 6 and SQL SERVER 2000
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





