I would like to open an existing workbook, select a work sheet and insert multiple rows at the top of the spreadsheet. Have the following code, but unsure of proper command & syntax for Insert row, and how to make it insert at row A1. - With DataSheet
-
.Sheets(2).Select
-
.Rows.Insert
-
.Cells(1, 1).Value = txtLine1
-
.Cells(2, 1).Value = txtLine2
-
.Cells(3, 1).Value = txtLine3
-
.Cells(4, 1).Value = txtLine4
-
End With
3 15797 NeoPa 32,556
Expert Mod 16PB
Assuming you have a variable lngXtra holding the number of extra rows required above A1. - With DataSheet
-
.Sheets(2).Select
-
Call .Range("A1:A" & lngXtra).EntireRow.Insert
-
.Cells(1, 1).Value = txtLine1
-
.Cells(2, 1).Value = txtLine2
-
.Cells(3, 1).Value = txtLine3
-
.Cells(4, 1).Value = txtLine4
-
End With
Assuming you have a variable lngXtra holding the number of extra rows required above A1. - With DataSheet
-
.Sheets(2).Select
-
Call .Range("A1:A" & lngXtra).EntireRow.Insert
-
.Cells(1, 1).Value = txtLine1
-
.Cells(2, 1).Value = txtLine2
-
.Cells(3, 1).Value = txtLine3
-
.Cells(4, 1).Value = txtLine4
-
End With
Works like a charm! Thanks!
NeoPa 32,556
Expert Mod 16PB
No problem.
I actually do a large amount of work in Excel too so that was an easy one ;)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: smonczka |
last post by:
I have a DTS package that needs to refresh data in 3 separate Excel
spreadsheets on a daily basis. The problem is that unless I manually
delete the previous day's data, it appends rather than...
|
by: Elaksomfan |
last post by:
Hi,
I am having trouble importing data from an excel spreadsheet into MS
SQL Server 2000 using DTS Wizard. The DTS import process is
successfull, no errors, but only 50 rows of approx. 1500 rows...
|
by: garry.oxnard |
last post by:
Can anyone help me to solve a problem which involves switching from
Access to Excel (then back to Access) programatically please?
I have an Excel template which, on open, also opens an Access...
|
by: sysmanint1 |
last post by:
I am a total neophyte at Visual Basic but found the following post and reply from Clint concerning a dynamic range.
Also, have never "posted" to a discussion
I have made a macro that works on...
|
by: smaczylo |
last post by:
Hello, I've recently been asked to work with Microsoft Access, and
while I feel quite comfortable with Excel, I'm at a complete loss with
databases. If someone could help me with this issue I'm...
|
by: Bob |
last post by:
Hi all,
I'm trying to import data, modify the data then insert it into a new
table. The code below works fine for it but it takes a really long
time for 15,000 odd records. Is there a way I...
|
by: slinky |
last post by:
Can an Excel spreadsheet or a section of one be embedded into an
Access form and serve as a subform from which other parts of the
Access form can get data? Thanks!
|
by: JFKJr |
last post by:
Hello everyone, I am trying to insert a picture in an excel spreadsheet cell using Access VBA.
The following excel VBA code is working perfectly fine and I am able to insert picture in "A1" cell....
|
by: MitchR |
last post by:
Good Morning Folks;
I have a question that is pretty far fetched but here goes nothing... I am looking to find a way to insert a macro into an Excel command button located in an Access VBA...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |