View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.misc
Mike Mike is offline
external usenet poster
 
Posts: 3,101
Default Subtotal with tax

With a few changes you could use this. If you would send my the workbook I
could get you started. Its up to you.

Private Sub getDataFromAccess()
'Needs reference the Axtive X Library 2.0 or higher
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sSQL As String, strConn
Dim rowNumber As Long

'C:\PathToYourMdb\Ilsa.mdb (Change)
strConn = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=C:\PathToYourMdb\Ilsa.mdb;Persist Security Info=False"

'sSQL = "Replace with your query"
sSQL = "SELECT Field1, Field2 From TableName"

Set cnn = New ADODB.Connection
Set rs = New ADODB.Recordset

cnn.Open strConn
rs.Open sSQL, cnn, adOpenStatic, adLockOptimistic
rowNumber = 2 'Starting Row Number for data
Do While (Not rs.EOF)
Range("A" & rowNumber) = rs.Fields("Field1").Value
Range("B" & rowNumber) = rs.Fields("Field2").Value
rowNumber = rowNumber + 1
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
cnn.Close
Set cnn = Nothing
End Sub

"Renee" wrote:

I can pull the data from Access that I need? Don't think I have heard of
that. I have entered some vba code but not created my own, I am just starting
to learn how to write it.

"Mike" wrote:

It will take vba code to do this. Do you know how to write code ? If it was
me instead of exporting it from access I would have excel pull the data I
needed.



"Renee" wrote:

You can't just explain it to me, cause I am going to be exporting and doing
these totals on a weekly basis so I need to know how.

"Mike" wrote:

Yes it can
I can help if you want to send me a copy of the workbook.



"Renee" wrote:

I have a query that I export from access to excel and would like to subtotal
each invoice listed on the sheet but also include the tax and grand total of
the invoice. Is this possible?