|
-
Jul 14th, 2005, 04:39 PM
#1
[RESOLVED] How to Insert a row in Excel ?
I have an excel file with data from A1 to A10, how would I insert a row before lets say, Row 5 ?
I have this code:
VB Code:
Dim xlApp As Excel.Application
Dim wkbTemplateBook As Excel.Workbook
Dim wksTemplateSheet As Excel.Worksheet
Set xlApp = New Excel.Application
Set wkbTemplateBook = xlApp.Workbooks.Open(Me.txtTemplate.Text)
Set wksTemplateSheet = wkbTemplateBook.Worksheets(1)
With wksTemplateSheet
' how to insert a row ?
End With
-
Jul 14th, 2005, 05:00 PM
#2
Re: How to Insert a row in Excel ?
VB Code:
wksTemplateSheet .Rows("4:4").Select
Selection.Insert Shift:=xlDown
Last edited by RobDog888; Jul 14th, 2005 at 05:09 PM.
Reason: fix tags
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 14th, 2005, 05:08 PM
#3
Re: How to Insert a row in Excel ?
Thanks RobDog888...
A not so important question: Is there a way to insert lets say 50 rows in one call ? or do I have to call the Insert 50 times in a loop ?
-
Jul 14th, 2005, 05:11 PM
#4
Re: How to Insert a row in Excel ?
What ever number of rows you select, that amount will be inserted. 
VB Code:
wksTemplateSheet.Rows("1:10").Select
Selection.Insert Shift:=xlDown
10 rows inserted.
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
|