Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Keep cell reference when picking up information from another database

I want to pick up information from another database and
maka a SQL question related to a cell in my sheet.
At recording the macro it took the information in the
cell, but not the reference to the cell itself. I changed
that reference to =Range('L1') and that was OK, but then I
got a "SQL syntaxproblem" at running the macro. This line
was the "problemline"
..Refresh BackgroundQuery:=False
How can I solve this problem?

Sheets("Art.").Select
Range("L5").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;DSN=p_bt;DB=p_bt;HOST=tellus;SERV=sqlexec;SR V
R=tellus_tli;PRO=onsoctcp;UID=btsln;PWD=dani" _
, Destination:=Range("M4"))
.Sql = Array( _
"SELECT art.art_no, art.art_descr" & Chr(13) & ""
& Chr(10) & "FROM p_bt:guda.art art" & Chr(13) & "" & Chr
(10) & "WHERE (art.art_no=range('L1')" _
)
.FieldNames = True
.RefreshStyle = xlInsertDeleteCells
.RowNumbers = False
.FillAdjacentFormulas = False
.RefreshOnFileOpen = False
.HasAutoFormat = True
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SavePassword = True
.SaveData = True
End With
End Sub


If anyone could help me please reply!

/Samuel.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Keep cell reference when picking up information from another database

I would suggest that you change
"WHERE (art.art_no=range('L1')"
to
"WHERE (art.art_no=" & range("L1")

"Samuel Lindgren" wrote in message
...
I want to pick up information from another database and
maka a SQL question related to a cell in my sheet.
At recording the macro it took the information in the
cell, but not the reference to the cell itself. I changed
that reference to =Range('L1') and that was OK, but then I
got a "SQL syntaxproblem" at running the macro. This line
was the "problemline"
.Refresh BackgroundQuery:=False
How can I solve this problem?

Sheets("Art.").Select
Range("L5").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"ODBC;DSN=p_bt;DB=p_bt;HOST=tellus;SERV=sqlexec;SR V
R=tellus_tli;PRO=onsoctcp;UID=btsln;PWD=dani" _
, Destination:=Range("M4"))
.Sql = Array( _
"SELECT art.art_no, art.art_descr" & Chr(13) & ""
& Chr(10) & "FROM p_bt:guda.art art" & Chr(13) & "" & Chr
(10) & "WHERE (art.art_no=range('L1')" _
)
.FieldNames = True
.RefreshStyle = xlInsertDeleteCells
.RowNumbers = False
.FillAdjacentFormulas = False
.RefreshOnFileOpen = False
.HasAutoFormat = True
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SavePassword = True
.SaveData = True
End With
End Sub


If anyone could help me please reply!

/Samuel.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Keep cell reference when picking up information from another database

Hello!
I tried according to your suggestion (see below) but got a wrong message

.Sql = Array( _
"SELECT art.art_no, art.art_descr" & Chr(13) & "" & Chr(10) &
"FROM p_bt:guda.art art" & Chr(13) & "" & Chr(10) & "WHERE (art.art_no=&
range "H1")" _
)
.FieldNames = True


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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
Picking specific rows from database Buzz Sawyer Excel Discussion (Misc queries) 1 July 11th 07 02:44 PM
Conditional Vlookup - Cherry picking information from the table ar Wannabe Efficient Excel Discussion (Misc queries) 6 January 12th 07 02:41 PM
Is it possible to use a cell reference to define the database? PerplexedinKY Excel Worksheet Functions 3 November 14th 06 09:00 PM
information function - does cell contain reference R of Steinke Excel Worksheet Functions 1 February 27th 06 09:57 PM
Keep cell reference when picking up information from another database Samuel Lindgren Excel Programming 1 January 7th 04 09:13 PM


All times are GMT +1. The time now is 09:40 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"