Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old September 13th, 2004, 03:21 AM
kiran_karnati kiran_karnati is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Braunschweig , Germany
Posts: 39 kiran_karnati User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 44 m 5 sec
Reputation Power: 6
Send a message via Yahoo to kiran_karnati
Unhappy search and select a cell in excel from access

Hallo everybody,

I have searched our forums to find wether any thread that can help me but unfortunately I did't find it.
I found somethings but I don't need that much of complexity because I just have to open an excel file in a specific location and I have to search a for value in that sheet and I have to select that cell .
I have to do this when the user clicks a button on an access form.
I wrote a code and its opening the file and also the specific sheet but not searching beacause I don't know how to get the value of that cell and also I have abserved that it is working only alternative times not everytime. I did't understand why it is working so...

please help me... this is the code that I wrote


Set xlApp = New Excel.Application
varPath = "C:\Dokumente und Einstellungen\Kiran Karnati\Desktop\EXCEL\Book2.xls"
With xlApp
.Visible = True
' and now I have to open a perticular Workbook whose path is in varPath variable and Perticular Sheet

Set xlWB = .Workbooks.Open(varPath, , False)
With xlWB.Sheets("Sheet1")

For i = 1 To 100
s1 = "C" & i
s2 = Range(s1).Value
If Val(s2) = 100 Then
Range(s1).Select
End If
Next i
End With
End With


Thank you in advance.
Kiran.

Reply With Quote
  #2  
Old September 13th, 2004, 08:32 AM
kiran_karnati kiran_karnati is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: Braunschweig , Germany
Posts: 39 kiran_karnati User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 44 m 5 sec
Reputation Power: 6
Send a message via Yahoo to kiran_karnati
Quote:
Originally Posted by kiran_karnati
Hallo everybody,

I have searched our forums to find wether any thread that can help me but unfortunately I did't find it.
I found somethings but I don't need that much of complexity because I just have to open an excel file in a specific location and I have to search a for value in that sheet and I have to select that cell .
I have to do this when the user clicks a button on an access form.
I wrote a code and its opening the file and also the specific sheet but not searching beacause I don't know how to get the value of that cell and also I have abserved that it is working only alternative times not everytime. I did't understand why it is working so...

please help me... this is the code that I wrote


Set xlApp = New Excel.Application
varPath = "C:\Dokumente und Einstellungen\Kiran Karnati\Desktop\EXCEL\Book2.xls"
With xlApp
.Visible = True
' and now I have to open a perticular Workbook whose path is in varPath variable and Perticular Sheet

Set xlWB = .Workbooks.Open(varPath, , False)
With xlWB.Sheets("Sheet1")

For i = 1 To 100
s1 = "C" & i
s2 = Range(s1).Value
If Val(s2) = 100 Then
Range(s1).Select
End If
Next i
End With
End With


Thank you in advance.
Kiran.

Thank you for every one who viewed this and thought to help me.
I found the solution for my problem and I want to post it here so that no one else will suffer for this problem. that is...

Private Sub Command47_Click()
Dim intKDVal As Integer
Dim xl As Excel.Application
Dim SA As Excel.Worksheet
Dim rows As Long
Dim maxval, temp, selrow, chkval As Integer

'As my file is too larg and takes 1 minute to open am changing the mouse pointer as a 'hour glass till it is opened
DoCmd.Hourglass True

Set xl = CreateObject("Excel.Application")
maxval = 0
selrow = 1
'Taking the value to search in the excel sheet from the access form
Text49.Value = Forms!TOP_200_JOBS_Form.sample_sub!Expr1.Value
chkval = Forms!TOP_200_JOBS_Form!Text49.Value
xl.Workbooks.Open "C:\Dokumente und Einstellungen\Kiran Karnati\Desktop\EXCEL\Touareg.HA+TA.2004-09-10.xls"
Set SA = xl.ActiveWorkbook.Sheets("Sheet0")
With SA
For rows = 3 To 65536
If .Cells(rows, 2).Value = chkval Then
temp = .Cells(rows, 17).Value
If temp > maxval Then
maxval = temp
selrow = rows
End If
End If
Next rows
'Now select the row which has the maximum value in the 17 column corresponding to 'the first column
.Cells(selrow, 2).Select
End With
'Now the excel sheet is shown to the user
xl.Visible = True
'Mouse pointer turned to normal
DoCmd.Hourglass False
Set SA = Nothing
'If you want to close the excel sheet you can close
'As I want to see the resulting selection I have commented them
'xl.Workbooks("HideCols.xls").Close savechanges:=True
'xl.Quit
Set xl = Nothing
End Sub

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > search and select a cell in excel from access


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 7 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek