Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default To put an automatic " End total " on column Currtotal

Hi There,

This query rund perfectly where I can extract data from
SAP via SQL server. However, I cannot get the " Sum total"
to appear automatically after end of data.

Please help , me to redefine the query in this respect.( I
tried in vain to use "compute(Currtotal)

Thanks a lot



Sub Trial()
Dim SQLstring, connstring As String
Dim Wkobj As Object
Dim Connobj As Object
Dim ObjParam1 As Object
Dim ObjParam2 As Object

'This is just to clearall on relevant sheet
Workbooks("SAPTrialBalance.xls").Worksheets(5).Act ivate
Workbooks("SAPTrialBalance.xls").Worksheets(5).Ran ge
("A1:IV50000").ClearContents


SQLstring = " SELECT AcctName,Segment_0,CurrTotal " & _
" FROM OACT T0" & _
" where Segment_04999"


connstring = "ODBC;DSN=SAP Business One;APP=Microsoft
Office XP;WSID=NB-MELB-
05;DATABASE=MacDermidGraphicArts;LANGUAGE=us_engli sh;Truste
d_Connection=Yes"

Set Wkobj = Workbooks("SAPTrialBalance.xls").Worksheets
(5).QueryTables
Set Connobj = Wkobj.Add(Connection:=connstring,
Destination:=Range("A1"), Sql:=SQLstring)
Connobj.Refresh

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default To put an automatic " End total " on column Currtotal

You'll need to detect the last row of the data loaded after the query is
run, then insert the total in the next available cell.
Try this.......

Dim lastrow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Cells(lastrow + 1, 1).Formula = "=sum(A1:A" & lastrow & ")"

Cheers
Nigel

"Rama" wrote in message
...
Hi There,

This query rund perfectly where I can extract data from
SAP via SQL server. However, I cannot get the " Sum total"
to appear automatically after end of data.

Please help , me to redefine the query in this respect.( I
tried in vain to use "compute(Currtotal)

Thanks a lot



Sub Trial()
Dim SQLstring, connstring As String
Dim Wkobj As Object
Dim Connobj As Object
Dim ObjParam1 As Object
Dim ObjParam2 As Object

'This is just to clearall on relevant sheet
Workbooks("SAPTrialBalance.xls").Worksheets(5).Act ivate
Workbooks("SAPTrialBalance.xls").Worksheets(5).Ran ge
("A1:IV50000").ClearContents


SQLstring = " SELECT AcctName,Segment_0,CurrTotal " & _
" FROM OACT T0" & _
" where Segment_04999"


connstring = "ODBC;DSN=SAP Business One;APP=Microsoft
Office XP;WSID=NB-MELB-
05;DATABASE=MacDermidGraphicArts;LANGUAGE=us_engli sh;Truste
d_Connection=Yes"

Set Wkobj = Workbooks("SAPTrialBalance.xls").Worksheets
(5).QueryTables
Set Connobj = Wkobj.Add(Connection:=connstring,
Destination:=Range("A1"), Sql:=SQLstring)
Connobj.Refresh

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default To put an automatic " End total " on column Currtotal

Thanks a lot, it works




-----Original Message-----
You'll need to detect the last row of the data loaded

after the query is
run, then insert the total in the next available cell.
Try this.......

Dim lastrow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Cells(lastrow + 1, 1).Formula = "=sum(A1:A" & lastrow

& ")"

Cheers
Nigel

"Rama" wrote in

message
...
Hi There,

This query rund perfectly where I can extract data from
SAP via SQL server. However, I cannot get the " Sum

total"
to appear automatically after end of data.

Please help , me to redefine the query in this respect.

( I
tried in vain to use "compute(Currtotal)

Thanks a lot



Sub Trial()
Dim SQLstring, connstring As String
Dim Wkobj As Object
Dim Connobj As Object
Dim ObjParam1 As Object
Dim ObjParam2 As Object

'This is just to clearall on relevant sheet
Workbooks("SAPTrialBalance.xls").Worksheets(5).Act ivate
Workbooks("SAPTrialBalance.xls").Worksheets(5).Ran ge
("A1:IV50000").ClearContents


SQLstring = " SELECT AcctName,Segment_0,CurrTotal " & _
" FROM OACT T0" & _
" where Segment_04999"


connstring = "ODBC;DSN=SAP Business One;APP=Microsoft
Office XP;WSID=NB-MELB-

05;DATABASE=MacDermidGraphicArts;LANGUAGE=us_engli sh;Truste
d_Connection=Yes"

Set Wkobj = Workbooks("SAPTrialBalance.xls").Worksheets
(5).QueryTables
Set Connobj = Wkobj.Add(Connection:=connstring,
Destination:=Range("A1"), Sql:=SQLstring)
Connobj.Refresh

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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
How do I change the column heading in Excel to display "A" "B" "C Thai New Users to Excel 1 November 30th 07 08:06 PM
Need column evaluated to count total of occurrences of "Y". How? learning Excel Worksheet Functions 2 June 12th 06 01:55 AM
Linking two "total" pages to create a "Complete Total" page Jordon Excel Worksheet Functions 0 January 10th 06 11:18 PM
Adding "TOTAL" and summing column Fred Butterfield Excel Programming 3 May 18th 04 02:20 AM


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