Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default VBA Sumproduct for External Source

Sub final()

ar1 = "'S:\Main Files\Daily Productivity\Current\[Current
Admin.xls]Data'!$A$1:$A$30000"
ar2 = "'S:\Main Files\Daily Productivity\Current\[Current
Admin.xls]Data'!$E$1:$E$30000"

ans = Calendar1.Value

If Not IsNumeric(ans) Then
ans = """" & ans & """"
End If
pct = Application.Evaluate("SUMPRODUCT((" & ar1 & "=" _
& ans & ")*(" & ar2 & "))")

With Label1
.Caption = Format(pct, "0%")
End With

End Sub

When this gets run it throws up a Run-Time error '13', and when I debug it
shows me that pct's value = Error 2023.
Anyway to get this to work? As a last resort I suppose I can enter the
formula into a new workbook then delete that workbook once it has the
answer...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default VBA Sumproduct for External Source

? cverr(xlErrRef)
Error 2023

I couldn't get your formula to work in code. I think you would need to open
the workbook you want to query.

--
Regards,
Tom Ogilvy


"PaulW" wrote:

Sub final()

ar1 = "'S:\Main Files\Daily Productivity\Current\[Current
Admin.xls]Data'!$A$1:$A$30000"
ar2 = "'S:\Main Files\Daily Productivity\Current\[Current
Admin.xls]Data'!$E$1:$E$30000"

ans = Calendar1.Value

If Not IsNumeric(ans) Then
ans = """" & ans & """"
End If
pct = Application.Evaluate("SUMPRODUCT((" & ar1 & "=" _
& ans & ")*(" & ar2 & "))")

With Label1
.Caption = Format(pct, "0%")
End With

End Sub

When this gets run it throws up a Run-Time error '13', and when I debug it
shows me that pct's value = Error 2023.
Anyway to get this to work? As a last resort I suppose I can enter the
formula into a new workbook then delete that workbook once it has the
answer...

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default VBA Sumproduct for External Source

I think that dropping the formula into a cell and then picking up the value
is the only way it will work. Excel can evaluate the formula over closed
workbooks, but VBA seems not to be able to.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"PaulW" wrote in message
...
Sub final()

ar1 = "'S:\Main Files\Daily Productivity\Current\[Current
Admin.xls]Data'!$A$1:$A$30000"
ar2 = "'S:\Main Files\Daily Productivity\Current\[Current
Admin.xls]Data'!$E$1:$E$30000"

ans = Calendar1.Value

If Not IsNumeric(ans) Then
ans = """" & ans & """"
End If
pct = Application.Evaluate("SUMPRODUCT((" & ar1 & "=" _
& ans & ")*(" & ar2 & "))")

With Label1
.Caption = Format(pct, "0%")
End With

End Sub

When this gets run it throws up a Run-Time error '13', and when I debug it
shows me that pct's value = Error 2023.
Anyway to get this to work? As a last resort I suppose I can enter the
formula into a new workbook then delete that workbook once it has the
answer...



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 130
Default VBA Sumproduct for External Source

First off, cheers for spending the time to look at this.

I was wanting a userform that could tell someone the productivity for
whatever team on whatever day, and I created the productivity to be like a
list so that other sheets could easily query it with sumproducts or a pivot
table.

I guess if I can't calculate the information straight from the sheets I can
use a preset workbook to open when the userform opens, and closes when the
userform closes and have the calculations present in there.

Cheers

"Tom Ogilvy" wrote:

? cverr(xlErrRef)
Error 2023

I couldn't get your formula to work in code. I think you would need to open
the workbook you want to query.

--
Regards,
Tom Ogilvy


"PaulW" wrote:

Sub final()

ar1 = "'S:\Main Files\Daily Productivity\Current\[Current
Admin.xls]Data'!$A$1:$A$30000"
ar2 = "'S:\Main Files\Daily Productivity\Current\[Current
Admin.xls]Data'!$E$1:$E$30000"

ans = Calendar1.Value

If Not IsNumeric(ans) Then
ans = """" & ans & """"
End If
pct = Application.Evaluate("SUMPRODUCT((" & ar1 & "=" _
& ans & ")*(" & ar2 & "))")

With Label1
.Caption = Format(pct, "0%")
End With

End Sub

When this gets run it throws up a Run-Time error '13', and when I debug it
shows me that pct's value = Error 2023.
Anyway to get this to work? As a last resort I suppose I can enter the
formula into a new workbook then delete that workbook once it has the
answer...

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
External data source Question Boy Excel Discussion (Misc queries) 0 April 21st 08 07:44 PM
ListBox external source DoctorG Excel Programming 4 July 18th 07 03:32 AM
External Database Source ericat04 Excel Worksheet Functions 0 April 11th 07 11:32 PM
UNC for external data source Kirk P. Excel Discussion (Misc queries) 0 December 18th 06 04:31 PM
External Data Source S Walker Excel Programming 0 February 16th 05 04:15 PM


All times are GMT +1. The time now is 09:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"