Click here to Skip to main content
15,888,216 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Waiting for a process to end uses too much CPU. Pin
Luc Pattyn18-Jun-09 12:05
sitebuilderLuc Pattyn18-Jun-09 12:05 
GeneralRe: Waiting for a process to end uses too much CPU. Pin
elajua18-Jun-09 14:39
elajua18-Jun-09 14:39 
GeneralRe: Waiting for a process to end uses too much CPU. Pin
Luc Pattyn18-Jun-09 14:52
sitebuilderLuc Pattyn18-Jun-09 14:52 
QuestionAny way to use constructor parameters within "dim as new"? Pin
supercat918-Jun-09 11:38
supercat918-Jun-09 11:38 
Questionwhat is the installation steps for windows application project ? Pin
ahlamissa18-Jun-09 10:23
ahlamissa18-Jun-09 10:23 
AnswerRe: what is the installation steps for windows application project ? Pin
EliottA18-Jun-09 10:53
EliottA18-Jun-09 10:53 
AnswerRe: what is the installation steps for windows application project ? Pin
Dave Kreskowiak18-Jun-09 11:28
mveDave Kreskowiak18-Jun-09 11:28 
QuestionScope (?) Problem in Excel VBA Pin
TheConfusedGuy18-Jun-09 9:29
TheConfusedGuy18-Jun-09 9:29 
Hello Everyone,

I hope you can help me out with this. If it is not posted to the correct forum could you point me in the proper direction? Onto the question:

I have written an application in excel that calculates the time it takes a train travel between two points accounting for permanent speed zones and temporary speed restrictions. The application works perfectly except for one (actually two) thing(s), consider the following:

Workbook 1 has a set of data for analysis, when I run the application the data is analyzed perfectly. Now, workbook 2 has a different set of data for analysis (for example speeds in place as forecasted 3 months out), when workbook 2 is analyzed it analyzes perfectly. HOWEVER, when I have both workbooks open at the same time to compare it seems like each gets confused as to what set of data should be analyzed.

The workbooks, well, application is set up as follows:

1. Data stored in Access DB
2. Workbooks pull appropriate data from DB and insert it into the appropriate tabs
3. Workbooks then process the data across more tabs
4. Funtions work from those tabs to present the analysis on a summary tab

So, each workbook has it own sheets holding the data in such a manner to allow for the analysis.

However, it seems like when both workbooks are open the first reads the data from the tabs of the second. I think the problem is that I am implicitly referencing tabs in the function I have written, and not explicitly referencing which tab I want to process. Here is a snippet of the offending code:

Function CalcSubRT(sArg As String, cArg As String, tArg As String, tLen As Integer) As Double
Application.Volatile
Dim c As Integer, t As Integer, i As Integer
Dim lm As Double, hm As Double, d As Double, rt As Double
i = 2
c = GetC(cArg)
t = GetT(tArg)
rt = 0
Do While Worksheets(sArg).Cells(i, c) <> ""
lm = Worksheets(sArg).Cells(i, c + 1)
hm = Worksheets(sArg).Cells(i, c + 2)
d = (hm - lm) * 5280
If Worksheets(sArg).Cells(i, c) <> 1 Then
If Worksheets(sArg).Cells(i - 1, c + t) < Worksheets(sArg).Cells(i, c + t) Then
d = d - (tLen / 2)
Else
If Worksheets(sArg).Cells(i - 1, c + t) > Worksheets(sArg).Cells(i, c + t) Then
d = d + tLen
End If
End If
End If
If Worksheets(sArg).Cells(i + 1, c) <> "" Then
If Worksheets(sArg).Cells(i + 1, c + t) > Worksheets(sArg).Cells(i, c + t) Then
d = d - (tLen / 2)
Else
If Worksheets(sArg).Cells(i + 1, c + t) < Worksheets(sArg).Cells(i, c + t) Then
d = d + tLen
End If
End If
End If
d = d / 5280
rt = rt + (d / Worksheets(sArg).Cells(i, c + t))
i = i + 1
Loop
CalcSubRT = rt
End Function

I think the problem lies in where I state Worksheets().Cells().

Any help would be much appreciated.
AnswerRe: Scope (?) Problem in Excel VBA Pin
Dave Kreskowiak18-Jun-09 9:56
mveDave Kreskowiak18-Jun-09 9:56 
QuestionContext Menu Pin
No-e18-Jun-09 6:23
No-e18-Jun-09 6:23 
AnswerRe: Context Menu Pin
Jon_Boy18-Jun-09 6:37
Jon_Boy18-Jun-09 6:37 
GeneralRe: Context Menu Pin
No-e18-Jun-09 12:08
No-e18-Jun-09 12:08 
GeneralRe: Context Menu Pin
Jon_Boy19-Jun-09 6:09
Jon_Boy19-Jun-09 6:09 
AnswerRe: Context Menu Pin
Bahram.Zarrin27-Jun-09 5:14
Bahram.Zarrin27-Jun-09 5:14 
Questionmultipage problem in printpreview? Pin
JC.KaNNaN18-Jun-09 4:03
JC.KaNNaN18-Jun-09 4:03 
AnswerRe: multipage problem in printpreview? Pin
Luc Pattyn18-Jun-09 4:47
sitebuilderLuc Pattyn18-Jun-09 4:47 
GeneralRe: multipage problem in printpreview? Pin
JC.KaNNaN18-Jun-09 22:19
JC.KaNNaN18-Jun-09 22:19 
QuestionEtracting certain text from PDF document into a database Pin
kshincsk18-Jun-09 3:31
kshincsk18-Jun-09 3:31 
AnswerRe: Etracting certain text from PDF document into a database Pin
Dave Kreskowiak18-Jun-09 9:58
mveDave Kreskowiak18-Jun-09 9:58 
GeneralRe: Etracting certain text from PDF document into a database Pin
kshincsk19-Jun-09 0:58
kshincsk19-Jun-09 0:58 
GeneralRe: Etracting certain text from PDF document into a database Pin
Dave Kreskowiak19-Jun-09 4:27
mveDave Kreskowiak19-Jun-09 4:27 
QuestionCopyMemory in VB.Net Pin
Knight_Rider18-Jun-09 2:57
Knight_Rider18-Jun-09 2:57 
AnswerRe: CopyMemory in VB.Net Pin
Luc Pattyn18-Jun-09 3:34
sitebuilderLuc Pattyn18-Jun-09 3:34 
GeneralRe: CopyMemory in VB.Net Pin
Knight_Rider18-Jun-09 3:39
Knight_Rider18-Jun-09 3:39 
GeneralRe: CopyMemory in VB.Net Pin
Luc Pattyn18-Jun-09 3:43
sitebuilderLuc Pattyn18-Jun-09 3:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.