Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 150
Default autonumber plus

I am keeping track of invoice revisions. .Each new worksheet is copied into
a new workbook. Worksheets are

grouped by worksheet number and renamed as by invoice number using the
following code.:

Public Sub RenameSheet()
NewName = Range("c7").Value & "-" & Range("h4").Value
ActiveSheet.Name = NewName
End Sub

Currently I have users enter a sequential value in h4. Range c7 contains
the invoice number, which must remain the same.

I would like to automate this part. So that it first looks to c7, copies
it, then addes a sequential number in h4, avoiding duplication and starting
with 1.

any help would be most appreciated

--
stan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default autonumber plus

Humm, you may find a use for this:

Sub InsertMissingNum()

Range("A2").Select
Do Until ActiveCell.Value = Empty
If ActiveCell.Value = ActiveCell.Offset(-1, 0).Value + 1 Then
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.EntireRow.Insert
ActiveCell.Value = ActiveCell.Offset(-1, 0).Value + 1
ActiveCell.Offset(1, 0).Select
End If
Loop

End Sub

It increments by 1, and inserts rows so your existing data stays the same,
relative to your new data.

So, let's say you have 1, 2, 3...8...10, all in Column A. Run the macro.
Does it do what you want?

HTH,
Ryan---


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"stan" wrote:

I am keeping track of invoice revisions. .Each new worksheet is copied into
a new workbook. Worksheets are

grouped by worksheet number and renamed as by invoice number using the
following code.:

Public Sub RenameSheet()
NewName = Range("c7").Value & "-" & Range("h4").Value
ActiveSheet.Name = NewName
End Sub

Currently I have users enter a sequential value in h4. Range c7 contains
the invoice number, which must remain the same.

I would like to automate this part. So that it first looks to c7, copies
it, then addes a sequential number in h4, avoiding duplication and starting
with 1.

any help would be most appreciated

--
stan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 150
Default autonumber plus

it solved the problem. thanks
--
stan


"ryguy7272" wrote:

Humm, you may find a use for this:

Sub InsertMissingNum()

Range("A2").Select
Do Until ActiveCell.Value = Empty
If ActiveCell.Value = ActiveCell.Offset(-1, 0).Value + 1 Then
ActiveCell.Offset(1, 0).Select
Else
ActiveCell.EntireRow.Insert
ActiveCell.Value = ActiveCell.Offset(-1, 0).Value + 1
ActiveCell.Offset(1, 0).Select
End If
Loop

End Sub

It increments by 1, and inserts rows so your existing data stays the same,
relative to your new data.

So, let's say you have 1, 2, 3...8...10, all in Column A. Run the macro.
Does it do what you want?

HTH,
Ryan---


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"stan" wrote:

I am keeping track of invoice revisions. .Each new worksheet is copied into
a new workbook. Worksheets are

grouped by worksheet number and renamed as by invoice number using the
following code.:

Public Sub RenameSheet()
NewName = Range("c7").Value & "-" & Range("h4").Value
ActiveSheet.Name = NewName
End Sub

Currently I have users enter a sequential value in h4. Range c7 contains
the invoice number, which must remain the same.

I would like to automate this part. So that it first looks to c7, copies
it, then addes a sequential number in h4, avoiding duplication and starting
with 1.

any help would be most appreciated

--
stan

Reply
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
AutoNumber bijan Excel Programming 4 December 13th 08 05:54 PM
AutoNumber/RecordID Marc Excel Programming 1 September 10th 07 03:48 PM
Excel Autonumber? Trent Argante[_2_] Excel Programming 6 May 11th 07 06:48 PM
autonumber Hardy Excel Discussion (Misc queries) 4 November 24th 05 05:40 PM
Question on autonumber Xenos Excel Programming 5 October 2nd 05 08:14 PM


All times are GMT +1. The time now is 07:20 AM.

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

About Us

"It's about Microsoft Excel"