Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,670
Default How to fix the coding?

Refer to the post under Worksheet

Working with the file E:\dir\file.xls, under the table sheet, cell C3 is 5,
and
cell C4 is 3.
When I run following codes, the MsgBox displays [file.xls]Table!C4 instead
of the value from this cell 3.
Could anyone give me any suggestions on how to fix it?
Thank everyone very much for any suggestions
Eric

Sub Test
x = TheValue("E:\dir", "file.xls", "Table", "C3")
y = TheValue("E:\dir", "file.xls", "Table", "C4")
If x = y Then
MsgBox ("The value was " & y)
End If
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,339
Default How to fix the coding?

"TheValue" is a UDF? and the code is ...?

"Eric" wrote:

Refer to the post under Worksheet

Working with the file E:\dir\file.xls, under the table sheet, cell C3 is 5,
and
cell C4 is 3.
When I run following codes, the MsgBox displays [file.xls]Table!C4 instead
of the value from this cell 3.
Could anyone give me any suggestions on how to fix it?
Thank everyone very much for any suggestions
Eric

Sub Test
x = TheValue("E:\dir", "file.xls", "Table", "C3")
y = TheValue("E:\dir", "file.xls", "Table", "C4")
If x = y Then
MsgBox ("The value was " & y)
End If
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default How to fix the coding?

Eric,

I think you have copied only part of the code, the function 'The Value' is
missing.

It looks like you are trying to read values from a closed(?) file so try
this:-

Sub human()
Application.DisplayAlerts = False
Path = "c:\" '<======<Change to suit
WorkbookName = "Book2.xls" '<======<Change to suit
Sheet = "Table" '<======<Change to suit
Addr1 = "C3"
Addr2 = "C4"
Worksheets.Add
Range("A1").Formula = "='" & Path & "\[" & WorkbookName & "]" & Sheet & "'!"
& Addr1
Range("A2").Formula = "='" & Path & "\[" & WorkbookName & "]" & Sheet & "'!"
& Addr2
x = Range("A1").Value
y = Range("A2").Value
ActiveSheet.Delete
If x = y Then
MsgBox ("The value was " & y)
End If
Application.DisplayAlerts = True
End Sub

Mike


"Eric" wrote:

Refer to the post under Worksheet

Working with the file E:\dir\file.xls, under the table sheet, cell C3 is 5,
and
cell C4 is 3.
When I run following codes, the MsgBox displays [file.xls]Table!C4 instead
of the value from this cell 3.
Could anyone give me any suggestions on how to fix it?
Thank everyone very much for any suggestions
Eric

Sub Test
x = TheValue("E:\dir", "file.xls", "Table", "C3")
y = TheValue("E:\dir", "file.xls", "Table", "C4")
If x = y Then
MsgBox ("The value was " & y)
End If
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,670
Default How to fix the coding?

There is the code for TheValue
Does anyone have any suggestions?
Thank everyone for any suggestions
Eric

Sub Test
x = TheValue("E:\dir", "file.xls", "Table", "C3")
y = TheValue("E:\dir", "file.xls", "Table", "C4")
If x = y Then
MsgBox ("The value was " & y)
End If
End Sub

Function TheValue(Path, WorkbookName, Sheet, Addr) As String
TheValue = "[" & WorkbookName & "]" & Sheet & "'!" & Addr
End Function


"Toppers" wrote:

"TheValue" is a UDF? and the code is ...?

"Eric" wrote:

Refer to the post under Worksheet

Working with the file E:\dir\file.xls, under the table sheet, cell C3 is 5,
and
cell C4 is 3.
When I run following codes, the MsgBox displays [file.xls]Table!C4 instead
of the value from this cell 3.
Could anyone give me any suggestions on how to fix it?
Thank everyone very much for any suggestions
Eric

Sub Test
x = TheValue("E:\dir", "file.xls", "Table", "C3")
y = TheValue("E:\dir", "file.xls", "Table", "C4")
If x = y Then
MsgBox ("The value was " & y)
End If
End Sub

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,670
Default How to fix the coding?

Thank everyone for suggestions
I try not to read any value from a closed file, so when I open
E:\dir\file.xls, all required values are already collected under worksheet
Table C3 & C4
Do you have any suggestions?
Thank everyone for any suggestions
Eric

Sub Test
x = TheValue("E:\dir", "file.xls", "Table", "C3")
y = TheValue("E:\dir", "file.xls", "Table", "C4")
If x = y Then
MsgBox ("The value was " & y)
End If

Function TheValue(Path, WorkbookName, Sheet, Addr) As String
TheValue = "[" & WorkbookName & "]" & Sheet & "'!" & Addr
End Function

End Sub


"Mike H" wrote:

Eric,

I think you have copied only part of the code, the function 'The Value' is
missing.

It looks like you are trying to read values from a closed(?) file so try
this:-

Sub human()
Application.DisplayAlerts = False
Path = "c:\" '<======<Change to suit
WorkbookName = "Book2.xls" '<======<Change to suit
Sheet = "Table" '<======<Change to suit
Addr1 = "C3"
Addr2 = "C4"
Worksheets.Add
Range("A1").Formula = "='" & Path & "\[" & WorkbookName & "]" & Sheet & "'!"
& Addr1
Range("A2").Formula = "='" & Path & "\[" & WorkbookName & "]" & Sheet & "'!"
& Addr2
x = Range("A1").Value
y = Range("A2").Value
ActiveSheet.Delete
If x = y Then
MsgBox ("The value was " & y)
End If
Application.DisplayAlerts = True
End Sub

Mike


"Eric" wrote:

Refer to the post under Worksheet

Working with the file E:\dir\file.xls, under the table sheet, cell C3 is 5,
and
cell C4 is 3.
When I run following codes, the MsgBox displays [file.xls]Table!C4 instead
of the value from this cell 3.
Could anyone give me any suggestions on how to fix it?
Thank everyone very much for any suggestions
Eric

Sub Test
x = TheValue("E:\dir", "file.xls", "Table", "C3")
y = TheValue("E:\dir", "file.xls", "Table", "C4")
If x = y Then
MsgBox ("The value was " & y)
End If
End Sub

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
coding maisy1 Excel Discussion (Misc queries) 1 August 6th 06 08:58 PM
help with coding in excel associates Excel Worksheet Functions 3 June 7th 06 10:41 AM
Coding metaltecks Excel Discussion (Misc queries) 1 April 17th 06 10:12 PM
Coding help request (I think?) adodson Excel Discussion (Misc queries) 7 November 24th 05 12:44 AM
coding Hardy Excel Discussion (Misc queries) 1 February 22nd 05 04:58 PM


All times are GMT +1. The time now is 03:04 PM.

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"