Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting Column with specified amount of Rows

Status
Not open for further replies.

VBAveenker

Technical User
May 23, 2007
10
US
I realize this is pretty basic, but I'm having trouble discovering how to insert a column with 29 rows in it. I have the code that allows me to insert the entire column (Selection.Entirecolumn.Insert) but can't figure out the basic syntax for inserting a column with only 29 rows. Below you will see that the code allows for only certain cells to be selected for the column to be inserted and auto fill's certain cells as well.

Any help is appreciated!

Selection.EntireColumn.Insert
Set selection1 = ActiveSheet.Range("c12")
Set selection2 = ActiveSheet.Range("c12:ah12")
'Autofill
selection1.AutoFill Destination:=selection2

Set selection3 = ActiveSheet.Range("c22")
Set selection4 = ActiveSheet.Range("c22:ah22")
selection3.AutoFill Destination:=selection4

Set selection5 = ActiveSheet.Range("c23")
Set selection6 = ActiveSheet.Range("c23:ah23")
selection5.AutoFill Destination:=selection6

Set selection7 = ActiveSheet.Range("c27")
Set selection8 = ActiveSheet.Range("c27:ah27")
selection7.AutoFill Destination:=selection8

Set selection9 = ActiveSheet.Range("c28")
Set selection10 = ActiveSheet.Range("c28:ah28")
selection9.AutoFill Destination:=selection10

Set selection11 = ActiveSheet.Range("c29")
Set selection12 = ActiveSheet.Range("c29:ah29")
selection11.AutoFill Destination:=selection12
End If
 
Yes - but it's just giving me the Range(" "," ").Select object. I need it to be any active cell that I select (within the parameters given. I didn't include that code previously).

Is there some snytax that I am missing concerning insertion of column with certain amount of rows? Thanks.

-Jason
 




I'm having trouble following what you have in you head, but are not expressing clearly.

You can insert a COLUMN, or you can insert a RANGE containing so many rows & columns. Which is it?



Skip,

[glasses] [red][/red]
[tongue]
 
Yeah - looking to insert a range of 1 column, 29 rows. However, it would allow me to select any cell in the worksheet and when the button is clicked, a "column" with 29 rows is inserted. Sorry for the confusion. Is that a little clearer?
 




Macro record doing JUST THAT! Post back with your code if you need help customizing.

Skip,

[glasses] [red][/red]
[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top