LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 201
Default Need VBA script to auto-insert value upon row insert

I have a spreadsheet that is tracking ownerships of land parcels for
importing into a database.

Currently it has about 300+ records (rows). In column A, there is a field
named Sort_Key. They are only whole numbers. The column is formatted as
GENERAL, which when using a whole number, would connote a INTEGER format,
right?

Anyway, the whole idea behind the sort key concept is to allow me a way to
revert back to the sequence that the data was originally entered, in case I
changed the way the spreadsheet was sorted.

I have been told that I will no longer be doing the data input on this
spreadsheet, and because of that, will be forwarding the task of data input
to a much a very inexperienced Excel user. This person will undoubtedly
forget to add the sort key value whenever he adds/inserts a new row, I fear.

To avert this potential catastrophe, the only thing that I can think of is
a VBA script that will automatically insert a new Sort_Key value that is +1
(incremented) from the highest previous value.

------------------------------------------------------------------
The work flow for understanding the construction of the VBA script is as
follows:

1 - User initializes INSERT ROW command.

2a - With Excel listening in the background for any INSERT ROW command, the
VBA script initializes.

2b - A dialog box will pop up informing the user that upon completion of the
VBA script, Excel is going to place a NEW, incremented value in the cell (in
Col A) on the new row, for the new Sort Key.

2c - The user will would be prompted to select EITHER: "YES - proceed with
new Sort Key Value" or "NO - I don't want to generate a new Sort Key at this
time". If the user selects "No ...", then it will return to the cursor
position, and the VBA script will abort.

3a - If the user selects "Yes..", then the VBA script will continue.

3b - The script will read in Col A the MAX value, insert it into the
variable to be incremented, then increment it by 1. The output will be
inserted in the new empty cell in Col A.

4 - Once this is done, the script will place the cursor in the next column
(which is named: Tract No), and the routine will end.

------------------------------------------------------------------
Some other questions/comments:

A) What if the user changes his mind and decides NOT to insert a row, and
wishes to UNDO the new Sort Key? What are the ramifications here, if any?

B) I was also thinking of another way to do this would be to have a custom
button that is assigned to the VBA script. Whenever the user wanted to
insert a new row, and then add a new Sort Key value. Since this could be
construed as a "deliberate" action, it would do away steps 1, 2, and 3a.

C) Is there a hidden value that Excel keeps that could be utilized (in some
way) to satisfy this application?

I hope that I've explained this sufficiently, but if not, please place your
questions and I will respond to them promptly.

Thanks in advance.

Phil
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto insert row: George Excel Worksheet Functions 1 November 6th 07 04:21 PM
auto insert jason2444 Excel Discussion (Misc queries) 2 January 3rd 07 07:36 PM
Can I auto insert a worksheet when I insert a value in a cell. iainc Excel Worksheet Functions 0 April 27th 06 08:37 AM
auto row insert Tsurphr Excel Worksheet Functions 0 October 11th 05 02:27 PM
Auto Insert of Rows Gar3th Excel Worksheet Functions 0 January 6th 05 08:33 PM


All times are GMT +1. The time now is 11:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"