Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Drag/fill colums and Delete Columns

I know I can drag/fill and delte a colum range as follows below from a
recorded macro. How do I use column numbers in VBA to replicate these acts?
Assume ahead of time I know for the drag/fill I kno my range is C2:C17.
Also assume that for the delete I know the starting range of C19:J32.

Thanks

'Drag and fill
Range("C2:C17").Select
Selection.AutoFill Destination:=Range("C2:J17"), Type:=xlFillDefault
Range("C2:J17").Select

'Delete Range
Range("C19:J32").Select
Range("J19").Activate
Selection.ClearContents
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Drag/fill colums and Delete Columns


ExcelMonkey Wrote:
I know I can drag/fill and delte a colum range as follows below from a
recorded macro. How do I use column numbers in VBA to replicate these
acts?
Assume ahead of time I know for the drag/fill I kno my range is
C2:C17.
Also assume that for the delete I know the starting range of C19:J32.

Thanks

'Drag and fill
Range("C2:C17").Select
Selection.AutoFill Destination:=Range("C2:J17"), Type:=xlFillDefault
Range("C2:J17").Select

'Delete Range
Range("C19:J32").Select
Range("J19").Activate
Selection.ClearContents


could be..
Range("C19:J32").Select
Selection.ClearContents
Range("C19").Select


the auto fill could be this

Range("C2").Select
Selection.AutoFill Destination:=Range("C2:C17"),
Type:=xlFillDefault
Range("D2").Select


--
davesexcel


------------------------------------------------------------------------
davesexcel's Profile: http://www.excelforum.com/member.php...o&userid=31708
View this thread: http://www.excelforum.com/showthread...hreadid=564089

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Drag/fill colums and Delete Columns

Sub fillcol()
Cells(2, 3).AutoFill Destination:=Range(Cells(2, 3), Cells(17, 3))
End Sub

for the active column
Sub fillcol()
ac=activecell.column
Cells(2, ac).AutoFill Destination:=Range(Cells(2,ac), Cells(17, ac))
End Sub

same idea for your delete
Range(Cells(2,3), Cells(17, 13)).clear
--
Don Guillett
SalesAid Software

"ExcelMonkey" wrote in message
...
I know I can drag/fill and delte a colum range as follows below from a
recorded macro. How do I use column numbers in VBA to replicate these
acts?
Assume ahead of time I know for the drag/fill I kno my range is C2:C17.
Also assume that for the delete I know the starting range of C19:J32.

Thanks

'Drag and fill
Range("C2:C17").Select
Selection.AutoFill Destination:=Range("C2:J17"), Type:=xlFillDefault
Range("C2:J17").Select

'Delete Range
Range("C19:J32").Select
Range("J19").Activate
Selection.ClearContents



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 553
Default Drag/fill colums and Delete Columns

So Don why is this not working: I am trying to fill range C3:C17 to F3:F17.

Sub fillcol()
Dim X As Integer


Range(Cells(3, 3), Cells(17, 3)).Select
Selection.AutoFill Destination:=Range(Cells(3, 6), Cells(17, 6))
End Sub

"Don Guillett" wrote:

Sub fillcol()
Cells(2, 3).AutoFill Destination:=Range(Cells(2, 3), Cells(17, 3))
End Sub

for the active column
Sub fillcol()
ac=activecell.column
Cells(2, ac).AutoFill Destination:=Range(Cells(2,ac), Cells(17, ac))
End Sub

same idea for your delete
Range(Cells(2,3), Cells(17, 13)).clear
--
Don Guillett
SalesAid Software

"ExcelMonkey" wrote in message
...
I know I can drag/fill and delte a colum range as follows below from a
recorded macro. How do I use column numbers in VBA to replicate these
acts?
Assume ahead of time I know for the drag/fill I kno my range is C2:C17.
Also assume that for the delete I know the starting range of C19:J32.

Thanks

'Drag and fill
Range("C2:C17").Select
Selection.AutoFill Destination:=Range("C2:J17"), Type:=xlFillDefault
Range("C2:J17").Select

'Delete Range
Range("C19:J32").Select
Range("J19").Activate
Selection.ClearContents




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Drag/fill colums and Delete Columns

I think? this is what you want.
You will notice that I also removed the selections. Learn to NOT select
unless necessary.

Sub fillcol()
Range(Cells(3, 3), Cells(17, 3)). _
AutoFill Destination:=Range(Cells(3, 3), Cells(17, 6))
'you had
'________________Range(Cells(3, 6), Cells(17, 6))

End Sub

--
Don Guillett
SalesAid Software

"ExcelMonkey" wrote in message
...
So Don why is this not working: I am trying to fill range C3:C17 to
F3:F17.

Sub fillcol()
Dim X As Integer


Range(Cells(3, 3), Cells(17, 3)).Select
Selection.AutoFill Destination:=Range(Cells(3, 6), Cells(17, 6))
End Sub

"Don Guillett" wrote:

Sub fillcol()
Cells(2, 3).AutoFill Destination:=Range(Cells(2, 3), Cells(17, 3))
End Sub

for the active column
Sub fillcol()
ac=activecell.column
Cells(2, ac).AutoFill Destination:=Range(Cells(2,ac), Cells(17, ac))
End Sub

same idea for your delete
Range(Cells(2,3), Cells(17, 13)).clear
--
Don Guillett
SalesAid Software

"ExcelMonkey" wrote in message
...
I know I can drag/fill and delte a colum range as follows below from a
recorded macro. How do I use column numbers in VBA to replicate these
acts?
Assume ahead of time I know for the drag/fill I kno my range is C2:C17.
Also assume that for the delete I know the starting range of C19:J32.

Thanks

'Drag and fill
Range("C2:C17").Select
Selection.AutoFill Destination:=Range("C2:J17"), Type:=xlFillDefault
Range("C2:J17").Select

'Delete Range
Range("C19:J32").Select
Range("J19").Activate
Selection.ClearContents






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
how do I drag and fill hyperlinks? coreygreat Excel Worksheet Functions 3 April 20th 10 02:10 PM
Fill & Drag to Right !! HELP ! Jez[_2_] Excel Discussion (Misc queries) 2 September 17th 09 03:12 PM
Why is my drag and fill not following the pattern? NAKA Excel Worksheet Functions 4 June 7th 09 05:08 PM
Drag down the color fill box inthestands Excel Discussion (Misc queries) 1 March 25th 09 02:00 PM
Drag and fill from other sheets LJ Excel Discussion (Misc queries) 3 September 4th 08 02:19 PM


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