Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 14th, 2008, 02:24 AM
Registered User
 
Join Date: Aug 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Automatically inserting rows at varied intervals

Hello,

I usually never use VBA or Excel, doing everything in R, as
I am econometrician.
But this time I have to automate another person's Excel file that contains lots of info, formulas, and plots.
The problem I have is following:
I have a sheet with an array of say (1000x20), the 20 columns
are named. Some of these columns contain data that never changes,
some contain data that must be filled in by hand, some contain
formulas that take data from other columns in the array.

Array is organized as follows:
one can see it as a collection of smaller arrays of (36x20). Sometimes
it can be (34x20) or (35x20), that is, number of rows vary.
Column NAME contains names of the companies, column DATE contains
date formatted like 01.01.1998. There is column ID, which contains
numeric ID for each company. Then there are columns that contain
formulas etc.
The smaller arrays are stacked, which means each array is for one
particular company, so in column NAME there are 36 occurencies
of one particular name, then 36 occurencies of another and co on.
Same goes for column ID. In column DATE there are 36 past months for each company.
The formula columns take data from other columns for each particular
firm.

WHAT I NEED TO DO EFFICIENTLY:
I need to write a piece of VBA code that inserts a new row
at the bottom of each smaller array (that is the row for
the new month), then fill in the cells in the row accordingly
That is copy in the name and the ID of the company
in columns NAME and ID, the new date (say 01.09.2008) in the DATE
column, and copy formulas from the row above.

I have done this with Do Until Loop, If statement, and using Offset
function a lot. My code finds column NAME and then it compares
each cell value in that column going down with the previous cell value, and when they differ I know the array for the next company starts and I insert new row, then Autofill date (using offset), copy name and ID from cells above, copy formulas.
This is very slow!!!

Anybody can suggest another, faster way to do these operations,
maybe counting similar IDs, and jumping to the last row containing
each particular ID, inserting rows, copying formulas "in bulk", etc

Really need some help, people.
Thank you in advance!

Regards,
Sergey

P.S. I have Excel 2007 VBA bible, it is great! But it did not help me to find solution to my problem, most likely because I am pretty much a complete novice when it comes to VBA.

Sergo





Similar Threads
Thread Thread Starter Forum Replies Last Post
Gridview and inserting rows thewoodchuck BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 0 April 10th, 2008 09:55 AM
Passing and Inserting mutliple rows at once SQLScott SQL Server 2005 4 February 12th, 2007 11:10 AM
Problem while inserting rows!! raman1 PHP Databases 0 April 16th, 2005 12:03 AM
Any code for automatically inserting queries of fi gilgalbiblewheel Classic ASP Databases 9 September 4th, 2004 12:12 PM
Automatically Finding and Deleting Blank rows Romulus Excel VBA 3 October 18th, 2003 09:04 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.