Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excel and Visual Basic

I have an excel 2007 spreadsheet that uses a Visual basic and sql to
populate. The procedure runs fine on all machines except two
machines. The program passes through one parameter and then clears
the work sheet and populates. The problem seems to be when the
worksheet is cleared. It just gets stuck

Sub ClearWorksheet()
Sheet1.Activate
Sheet1.Range("a5:az65000").Select
Selection.ClearContents
End Sub

If we change the above to only do this

Sub ClearWorksheet()
Sheet1.Activate
Sheet1.Range("a5:az1000").Select
Selection.ClearContents
End Sub

it runs but we need it to clear all 65000 rows or whatever the amount
might be.

Any body have any thoughts?

Here is the rest of the code:

Private Sub refreshbutton_Click()

Dim adoConnection As ADODB.Connection
Dim adoCMD As ADODB.Command
Dim adoRS As ADODB.Recordset
Dim adoPRM(1) As ADODB.Parameter
Dim strRange As String
Dim intRows As Integer


UserForm1.Show vbModal

If Not (UserForm1.blnContinue) Then
Unload UserForm1
Exit Sub
End If




ClearWorksheet

Set adoConnection = New ADODB.Connection
adoConnection.CursorLocation = adUseClient
adoConnection.ConnectionString =
"UID=;PWD=;DSN=SQL_server;DATABASE=MERION"
adoConnection.Open

Set adoCMD = New ADODB.Command
adoCMD.ActiveConnection = adoConnection
adoCMD.CommandType = adCmdStoredProc
adoCMD.CommandText = "XLS_rpt_SalesAnalysis"
adoCMD.CommandTimeout = 600
Set adoPRM(1) = adoCMD.CreateParameter("Publication", adChar,
adParamInput, 6, UserForm1.strPub)

adoCMD.Parameters.Append adoPRM(1)
Set adoRS = adoCMD.Execute

Unload UserForm1
Set UserForm1 = Nothing

Worksheets("Sheet1").Range("A5").CopyFromRecordset adoRS

Sheet1.Activate

End Sub

Sub ClearWorksheet()
Sheet1.Activate
Sheet1.Range("a5:az65000").Select
Selection.ClearContents
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Excel and Visual Basic

Does this work:

Sub ClearWorksheet()
Sheet1.Range("a:az").ClearContents
End Sub


- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Pam" wrote in message
...
I have an excel 2007 spreadsheet that uses a Visual basic and sql to
populate. The procedure runs fine on all machines except two
machines. The program passes through one parameter and then clears
the work sheet and populates. The problem seems to be when the
worksheet is cleared. It just gets stuck

Sub ClearWorksheet()
Sheet1.Activate
Sheet1.Range("a5:az65000").Select
Selection.ClearContents
End Sub

If we change the above to only do this

Sub ClearWorksheet()
Sheet1.Activate
Sheet1.Range("a5:az1000").Select
Selection.ClearContents
End Sub

it runs but we need it to clear all 65000 rows or whatever the amount
might be.

Any body have any thoughts?

Here is the rest of the code:

Private Sub refreshbutton_Click()

Dim adoConnection As ADODB.Connection
Dim adoCMD As ADODB.Command
Dim adoRS As ADODB.Recordset
Dim adoPRM(1) As ADODB.Parameter
Dim strRange As String
Dim intRows As Integer


UserForm1.Show vbModal

If Not (UserForm1.blnContinue) Then
Unload UserForm1
Exit Sub
End If




ClearWorksheet

Set adoConnection = New ADODB.Connection
adoConnection.CursorLocation = adUseClient
adoConnection.ConnectionString =
"UID=;PWD=;DSN=SQL_server;DATABASE=MERION"
adoConnection.Open

Set adoCMD = New ADODB.Command
adoCMD.ActiveConnection = adoConnection
adoCMD.CommandType = adCmdStoredProc
adoCMD.CommandText = "XLS_rpt_SalesAnalysis"
adoCMD.CommandTimeout = 600
Set adoPRM(1) = adoCMD.CreateParameter("Publication", adChar,
adParamInput, 6, UserForm1.strPub)

adoCMD.Parameters.Append adoPRM(1)
Set adoRS = adoCMD.Execute

Unload UserForm1
Set UserForm1 = Nothing

Worksheets("Sheet1").Range("A5").CopyFromRecordset adoRS

Sheet1.Activate

End Sub

Sub ClearWorksheet()
Sheet1.Activate
Sheet1.Range("a5:az65000").Select
Selection.ClearContents
End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 968
Default Excel and Visual Basic

This problem can be caused by the Google Office COM-addins.

To switch them off:
Office Button--Excel Options--Addins--choose Com addins in the pulldown
at the bottom --Go--Uncheck all Google Desktop Addins

Charles
__________________________________________________
Outlines for my Sessions at the Australia Excel Users Group
http://www.decisionmodels.com/OZEUC.htm

"Pam" wrote in message
...
I have an excel 2007 spreadsheet that uses a Visual basic and sql to
populate. The procedure runs fine on all machines except two
machines. The program passes through one parameter and then clears
the work sheet and populates. The problem seems to be when the
worksheet is cleared. It just gets stuck

Sub ClearWorksheet()
Sheet1.Activate
Sheet1.Range("a5:az65000").Select
Selection.ClearContents
End Sub

If we change the above to only do this

Sub ClearWorksheet()
Sheet1.Activate
Sheet1.Range("a5:az1000").Select
Selection.ClearContents
End Sub

it runs but we need it to clear all 65000 rows or whatever the amount
might be.

Any body have any thoughts?

Here is the rest of the code:

Private Sub refreshbutton_Click()

Dim adoConnection As ADODB.Connection
Dim adoCMD As ADODB.Command
Dim adoRS As ADODB.Recordset
Dim adoPRM(1) As ADODB.Parameter
Dim strRange As String
Dim intRows As Integer


UserForm1.Show vbModal

If Not (UserForm1.blnContinue) Then
Unload UserForm1
Exit Sub
End If




ClearWorksheet

Set adoConnection = New ADODB.Connection
adoConnection.CursorLocation = adUseClient
adoConnection.ConnectionString =
"UID=;PWD=;DSN=SQL_server;DATABASE=MERION"
adoConnection.Open

Set adoCMD = New ADODB.Command
adoCMD.ActiveConnection = adoConnection
adoCMD.CommandType = adCmdStoredProc
adoCMD.CommandText = "XLS_rpt_SalesAnalysis"
adoCMD.CommandTimeout = 600
Set adoPRM(1) = adoCMD.CreateParameter("Publication", adChar,
adParamInput, 6, UserForm1.strPub)

adoCMD.Parameters.Append adoPRM(1)
Set adoRS = adoCMD.Execute

Unload UserForm1
Set UserForm1 = Nothing

Worksheets("Sheet1").Range("A5").CopyFromRecordset adoRS

Sheet1.Activate

End Sub

Sub ClearWorksheet()
Sheet1.Activate
Sheet1.Range("a5:az65000").Select
Selection.ClearContents
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
Is Visual Basic the same as Visual Studio 2008? Mike Stewart Excel Worksheet Functions 5 January 11th 09 04:58 PM
Programmatic access to visual basic project via Visual FoxPro Jim Rech Excel Programming 0 January 11th 07 01:53 PM
Make visual basic truely visual! GraphicalGuy Excel Programming 0 October 20th 06 05:53 PM
Can I run Visual Basic procedure using Excel Visual Basic editor? john.jacobs71[_2_] Excel Programming 3 December 26th 05 02:22 PM
changing the visual basic in office 2003 to visual studio net bigdaddy3 Excel Discussion (Misc queries) 1 September 13th 05 10:57 AM


All times are GMT +1. The time now is 05:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"