#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 349
Default Autofill

Hello All,
I am trying to find out how to make autofill work in my workbook like this:

New sheet loads into workbook
Range K16 to K45 then needs to be autofilled with numbers.
The numbers will be diffrent for each new sheet that loads, but will carry
on from the sheet before.

ie: sheet1 will contain 1-30, sheet 2 will be 31-60, sheet3 will be 61-90
etc etc

Any idea's welcomed.
Regards
Peter
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Autofill

Assumes when you "Load" a sheet it will be placed directly after the last
sheet you "Loaded" (in the tab order)

Sub AA()
Dim sh As Worksheet
Dim i As Long
On Error Resume Next
Set sh = ActiveSheet.Previous
On Error GoTo 0
If Not sh Is Nothing Then
i = sh.Range("K45") + 1
Else
i = 1
End If
With ActiveSheet
.Range("K16").Value = i
.Range("K17").Value = i + 1
.Range("K16:K17").AutoFill _
Destination:=.Range("K16:K45"), _
Type:=xlFillDefault
End With
End Sub


--
Regards,
Tom Ogilvy




"Peter" wrote in message
...
Hello All,
I am trying to find out how to make autofill work in my workbook like

this:

New sheet loads into workbook
Range K16 to K45 then needs to be autofilled with numbers.
The numbers will be diffrent for each new sheet that loads, but will carry
on from the sheet before.

ie: sheet1 will contain 1-30, sheet 2 will be 31-60, sheet3 will be 61-90
etc etc

Any idea's welcomed.
Regards
Peter



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 349
Default Autofill

Thanks Tom
Worked exactly as I had hoped.

Regards
Peter

"Tom Ogilvy" wrote:

Assumes when you "Load" a sheet it will be placed directly after the last
sheet you "Loaded" (in the tab order)

Sub AA()
Dim sh As Worksheet
Dim i As Long
On Error Resume Next
Set sh = ActiveSheet.Previous
On Error GoTo 0
If Not sh Is Nothing Then
i = sh.Range("K45") + 1
Else
i = 1
End If
With ActiveSheet
.Range("K16").Value = i
.Range("K17").Value = i + 1
.Range("K16:K17").AutoFill _
Destination:=.Range("K16:K45"), _
Type:=xlFillDefault
End With
End Sub


--
Regards,
Tom Ogilvy




"Peter" wrote in message
...
Hello All,
I am trying to find out how to make autofill work in my workbook like

this:

New sheet loads into workbook
Range K16 to K45 then needs to be autofilled with numbers.
The numbers will be diffrent for each new sheet that loads, but will carry
on from the sheet before.

ie: sheet1 will contain 1-30, sheet 2 will be 31-60, sheet3 will be 61-90
etc etc

Any idea's welcomed.
Regards
Peter




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
AutoFill Student Excel Discussion (Misc queries) 2 May 30th 06 01:29 PM
Autofill until uberathlete Excel Discussion (Misc queries) 1 November 9th 05 06:01 PM
Autofill Dolphinv4 Excel Discussion (Misc queries) 2 October 21st 05 12:34 PM
Autofill: Need to autofill one week block, (5) weekday only into cells. dstock Excel Discussion (Misc queries) 1 June 17th 05 08:21 PM
Q. Autofill question: Can I autofill alpha characters like I can numbers? George[_22_] Excel Programming 5 August 7th 04 10:33 AM


All times are GMT +1. The time now is 04:07 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"