473,748 Members | 6,161 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inserting rows in Excel from Access

I have an Excel workbook that I'm programming from Access. The rows in
the workbook vary in height. So let's say row 8 is taller than the
rows above it. If I *manually* insert 2 new rows at the top, row 8
becomes row 10 and row 10 is now the taller row. That’s the way I want
it to be.

But when I insert lines using VBA code, row 8 remains taller and row
10 is shorter. That messes up the way my data is displayed.

Is there a way to get the spreadsheet to work the same way when
inserting rows with VBA as it does when the rows are inserted
manually?

Here’s the relevant section of my code:

‘Create a new Excel workbook based on a template workbook and
‘then activate the first worksheet so we can edit it.
Set objXLApp = CreateObject("E xcel.Applicatio n")
objXLApp.Workbo oks.Open (strTemplatePat h)
objXLApp.Active Workbook.SaveAs (strTargetPath)
Set objXLws = objXLApp.Active Workbook.Worksh eets(strWorkshe etName)
objXLws.Activat e

With objXLws
‘Insert as many new rows as there are records to insert.
For lngRow = 1 To lngRecordCount
.Range("A4:E4") .Insert -4121
Next
End With

After that, I populate the newly inserted rows using data in an Access
recordset.
Nov 12 '08 #1
1 4417
Apply the layout code after the data and row alterations. Make a sub
that simply does the layout formatting you want, and call it when
appropriate. I know this isnt ideal, but it works for me :-)

Cheers

The Frog
Nov 14 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1773
by: Jan Willems | last post by:
Hi, We use a database with about 40 related tables. Some tables contain as much as 30.000 records. We use Access97 as an interface to the database. Now recently we have the problem that when we want to insert a row in one specific table (alwasy the same) the database makes blocks. Details: - about 10% of the data was inserted using copying from Excel, before
3
6919
by: Joachim Klassen | last post by:
Hi all, first apologies if this question looks the same as another one I recently posted - its a different thing but for the same szenario:-). We are having performance problems when inserting/deleting rows from a large table. My scenario: Table (lets call it FACT1) with 1000 million rows distributed on 12
13
7781
by: Dixie | last post by:
How do I, in VBA from an access form module, add 5 rows to the top of a spreadsheet called MySpreadsheet.xls. The worksheet is called MyWorksheet and there is already data in the first 5 rows. I simply need to insert 5 blank rows at the top and move the rest of the data down so it starts at row 6. dixie
8
10109
by: LimaCharlie | last post by:
Hi, Question pls. I have an MS SQL local package where it exports data from SQL table to Excel file. My question is, how can I erase all the records in my excel file before i export the new data from SQL table? What i want is to delete the rows in the destination file before inserting new records. Note: I cannot do the drop & recreate table because the users has no permission to do this in the database. Only the DB admin is allowed...
0
1417
by: Christopher | last post by:
Hello, I am writing a little application which uses a template excel file and adds some information and then stores the changed file. The problem is, i don't really know how to add these rows - row by row. I can insert a range, but when I insert a range the data that is written below that isn't shifted down like I ment it would/should. Here is some sample code:
0
1511
by: eBob.com | last post by:
Here's how I insert and size pictures in an Excel spreadsheet which I create via a VB.NET program (commentary follows): 'add thumb nail objSheet.Rows(XLRow.ToString).rowheight = mpThumbNailHeight / 7 objSheet.Range("S" & XLRow.ToString).Select() objSheet.Pictures.insert(mpThumbNailLoc) 'size thumb nail - because they often end up different sizes although they all
1
5409
by: anon3803 | last post by:
I have a report in Access that has a lot of grouping (sometimes over 5 group headers). When I export it to Excel where more people can use it and are familiar it creates a lot of blank rows when there's nothing inside the group. Certain items in the report will have items in all 5 group headers/levels, most will not. I have a macro in Excel that deletes the blank rows but some reports are too long to export to Excel because of the blank rows....
2
3119
by: hakkatil | last post by:
Hi to all, I have a page that inserts excel sheet to access database. I am using asp. What I want to do is to check the inserting record if it is in the database. Basicly checking the dublicate record. My code inserts records one by one using addnew-updatebatch. If there is a duplicate in the db, it will display "already exists" and if it is not in the db it will display "record added". Below is my asp code I found on the net and...
1
11301
by: brionesl | last post by:
Hi, I have seen other threads with the same question but I'm not too familiar with Access and their solutions often include writing VB code or very complex SQL statements. What I want to do is display each city in which there are offices as columns and the respective user names in rows underneath the columns. This is how the data needs to appear in Excel: New York San Diego Kansas City Smith, John Smith, Jane Correia, Sabrina Brown,...
0
8989
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8828
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9319
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8241
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6795
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.