Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 11th, 2005, 10:56 AM
Authorized User
Join Date: Jun 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Excel Formula End Range Changes when Macro Is Run

I have a formula when I run the VB marco the end range reduces by 1000.
Example: Before I run the VB macro.

Example: After I run the VB macro.

I get the data in Sheet TestingDetails from an SQL query from my database.
zConnectionString = _
"Provider=SQLOLEDB.1;Password=xxxxxxx;Persist Security Info=True;" + _
"User ID=xxxx;Initial Catalog=SarbOxPortalV12;Data Source=someserver02;"

    zSQL = "select DISTINCT ProcBusCycl, OrgUnitName, ProcName,CntrlName,CntrlSignif, TestName, DocTitle, TestDesc, TestStatus, TestResultSum, TestTester, TestEndDate, TestCmpltStatus, CntrlType2, RTRIM(LTRIM(LEFT(CntrlName, CHARINDEX(';',CntrlName)+1))) As cName from ObjSrchTypViewProcRskMatTstDtls Where OrgUnitName NOT LIKE '%xxxxx%'And TestType IN ('P - Annual Test ')ORDER BY CntrlName"
    Set zConnection = New ADODB.Connection
    zConnection.ConnectionString = zConnectionString
    Set zRecordset = New ADODB.Recordset
    zRecordset.CursorLocation = CursorLocationEnum.adUseClient
    zRecordset.CursorType = CursorTypeEnum.adOpenStatic
    zRecordset.LockType = LockTypeEnum.adLockBatchOptimistic
    Call zRecordset.Open(zSQL, zConnection, , , CommandTypeEnum.adCmdText)
   Call Sheet3.Range("A2").CopyFromRecordset(zRecordset)
   Set zRecordset.ActiveConnection = Nothing
   Set zConnection = Nothing

Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Formula End Range Changes when Macro Is Run maaron Beginning VB 6 0 October 11th, 2005 10:33 AM
Run macro when exit/close excel dgilford Excel VBA 1 September 8th, 2005 02:42 AM
Cell returns its own formula after a macro! timoma Excel VBA 2 December 19th, 2004 03:48 PM
CurrentArray Range in Formula pagates Excel VBA 1 October 5th, 2004 03:53 AM
Error setting Formula Array property for a Range arnowitz Excel VBA 2 February 5th, 2004 02:08 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.