+ Reply to Thread
Results 1 to 3 of 3

Probelm in calculating formula in excel vba

Hybrid View

gamaz Probelm in calculating... 05-05-2010, 10:57 AM
antoka05 Re: Probelm in calculating... 05-05-2010, 11:21 AM
gamaz Re: Probelm in calculating... 05-05-2010, 12:55 PM
  1. #1
    Registered User
    Join Date
    07-15-2009
    Location
    Rockford, IL
    MS-Off Ver
    Excel 2003
    Posts
    38

    Probelm in calculating formula in excel vba

    Hi,
    I have a access report that exports to excel with click of a button after choosing parameters. This works well. However I have to modify couple of fields to utilize formula in the export module. I am not sure how to do this. I am writing the above code which seems to cause problem. I appreciate any help to resolve this issue. Thanks.



    If lngColumn = 12 Then
      xlc.Offset(0, lngColumn).Value = =([UnitPrice]*[OriginalShippedQty])/1000
    End If

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: Probelm in calculating formula in excel vba

    If you need to put VBA code in Ms Access and your Excel file is closed I think you need something as this:
    Dim xl As Object
    Dim ws As Worksheet
    
    Set xl = CreateObject("excel.application")
    xl.Workbooks.Open FileName:="c:\<file name>.xls"
    Set ws = xl.ActiveWorkbook.ActiveSheet
    'here put your formula, i.e.:
    ws.range("a1").formula = "=sum(a2:a100)"
    'save file
    xl.ActiveWorkbook.Close True
    xl.Quit
    Set xl = Nothing
    Regards,
    Antonio

  3. #3
    Registered User
    Join Date
    07-15-2009
    Location
    Rockford, IL
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: Probelm in calculating formula in excel vba

    Thanks Antonio for your help. Actually I am writing the vba in the access vba and using a query to loop through the query and output the values in excel file. My problem is exporting formula to excel. The formula example is something I have provided.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1