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

Is there a way to modify this code with some 'autofill' in order to copy the
formula down that is located in Column C and D?

Sub test()
Dim InsertionPoint As Range, rg As Range
Dim colToCheck As String
Dim expandBy As Long
Dim wsh As Worksheet
Set wsh = ActiveSheet
colToCheck = "A"
expandBy = 25
'Find last currently used row in column colToCheck
Set InsertionPoint = wsh.Range(colToCheck & 65536).End(xlUp).Offset(1,
0).EntireRow

'Insert rows
Set rg = InsertionPoint.Resize(expandBy)
rg.Insert

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Autofill

Try this version:

Sub test()
Dim InsertionPoint As Range, rg As Range
Dim colToCheck As String
Dim expandBy As Long
Dim wsh As Worksheet
Dim StartRow As Long

Set wsh = ActiveSheet
colToCheck = "A"
expandBy = 25
'Find last currently used row in column colToCheck
Set InsertionPoint = wsh.Range(colToCheck & 65536).End(xlUp).Offset(1, 0).EntireRow
StartRow = InsertionPoint.Row - 1

'Insert rows
Set rg = InsertionPoint.Resize(expandBy)
rg.Insert

Range("C" & StartRow).Resize(1, 2).Copy _
Range("C" & StartRow).Resize(expandBy + 1, 2)

End Sub

HTH,
Bernie
MS Excel MVP


"Coal Miner" wrote in message
...
Is there a way to modify this code with some 'autofill' in order to copy the
formula down that is located in Column C and D?

Sub test()
Dim InsertionPoint As Range, rg As Range
Dim colToCheck As String
Dim expandBy As Long
Dim wsh As Worksheet
Set wsh = ActiveSheet
colToCheck = "A"
expandBy = 25
'Find last currently used row in column colToCheck
Set InsertionPoint = wsh.Range(colToCheck & 65536).End(xlUp).Offset(1,
0).EntireRow

'Insert rows
Set rg = InsertionPoint.Resize(expandBy)
rg.Insert



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

Thanks so much Bernie. Have a good day!!! :)

"Bernie Deitrick" wrote:

Try this version:

Sub test()
Dim InsertionPoint As Range, rg As Range
Dim colToCheck As String
Dim expandBy As Long
Dim wsh As Worksheet
Dim StartRow As Long

Set wsh = ActiveSheet
colToCheck = "A"
expandBy = 25
'Find last currently used row in column colToCheck
Set InsertionPoint = wsh.Range(colToCheck & 65536).End(xlUp).Offset(1, 0).EntireRow
StartRow = InsertionPoint.Row - 1

'Insert rows
Set rg = InsertionPoint.Resize(expandBy)
rg.Insert

Range("C" & StartRow).Resize(1, 2).Copy _
Range("C" & StartRow).Resize(expandBy + 1, 2)

End Sub

HTH,
Bernie
MS Excel MVP


"Coal Miner" wrote in message
...
Is there a way to modify this code with some 'autofill' in order to copy the
formula down that is located in Column C and D?

Sub test()
Dim InsertionPoint As Range, rg As Range
Dim colToCheck As String
Dim expandBy As Long
Dim wsh As Worksheet
Set wsh = ActiveSheet
colToCheck = "A"
expandBy = 25
'Find last currently used row in column colToCheck
Set InsertionPoint = wsh.Range(colToCheck & 65536).End(xlUp).Offset(1,
0).EntireRow

'Insert rows
Set rg = InsertionPoint.Resize(expandBy)
rg.Insert




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Autofill

Thanks so much Bernie. Have a good day!!! :)

You're welcome.... and I will, thanks - I'm heading home in 15 minutes 8-)

Bernie


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 A to Z Hardeep kanwar New Users to Excel 4 March 29th 09 07:59 AM
AutoFill autofill Excel Discussion (Misc queries) 1 February 20th 06 08:29 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
Help With Autofill Jason Excel Programming 6 October 5th 04 04:05 AM
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 05:33 PM.

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"