|
-
Jul 14th, 2005, 07:25 PM
#1
Thread Starter
Lively Member
[Resolved] Deleting Rows in Excel via Access
In my code, I am trying to delete a selected set of rows using:
VB Code:
'delete rows
If count > 0 Then
Rows("1:12").Select
Selection.Delete Shift:=xlUp
End If
When ran, it carries out the deletion. However when I close excel/quit the application, an excel instance still remains - until I stop the process.
From reading past posts, this is symtom of incorrect code that works (?)...causing an excel instance to hang. The soluiton is to pin-point the code that is causing this. In my case Rows("1:12").Select is the problem.
Is there another way to delete rows in excel?
Last edited by whiteWay; Jul 16th, 2005 at 11:47 AM.
-
Jul 16th, 2005, 11:36 AM
#2
Re: Deleting Rows in Excel via Access
You need to post the code you wrote to create the Excel application instance and open the workbook, etc. I see your using
the default objects "Rows" and the "Selection" object. Where are your variable objects that fully qualify them? That is the problem and
you may also not be quiting the app using your Excel application onject.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 16th, 2005, 11:43 AM
#3
Thread Starter
Lively Member
Re: Deleting Rows in Excel via Access
When referencing Excel objects from Access, use the parent object to get methods/properties. When cutting and pasting from an excel macro, excel omits the parent object (in this case the application object and current sheet)
VB Code:
Dim xlApp As Excel.Application, sheet As Excel.Worksheet
With xlApp
Set sheet = .ActiveWorkbook.Sheets("Header")
'delete rows
If count > 0 Then
sheet.Rows("1:12").Select
.Selection.Delete Shift:=xlUp
End If
end With
-
Jul 16th, 2005, 11:45 AM
#4
Thread Starter
Lively Member
Re: Deleting Rows in Excel via Access
Sorry, we posted at the same time.
I finally figured it out myself, and you were right as well. Thanks.
-
Jul 16th, 2005, 11:54 AM
#5
Re: [Resolved] Deleting Rows in Excel via Access
's on solving it. 
Its not a waste because some member may do a search or read this thread and it will help them, etc.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|