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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel macro that inserts rows 2

Status
Not open for further replies.

pmtc

Technical User
Aug 15, 2002
3
0
0
CA
Hi All I am hoping someone can help me with this macro. I am trying to write a sub that will allow the user to click any cell in a row, run the macro, and insert the desired number of rows based on the users input. I can not get the "Rows" statement to accept my variables, any help would be appreciated.


Code:
Sub InsertRows()

Dim I As Integer
Dim C As Integer
Dim T As Integer
    I = InputBox("How many rows would you like to add?", "Add Rows above selected")
    C = ActiveCell.Row
    T = C + (I - 1)
        Rows("C:T").Select
        Selection.Insert Shift:=xlDown
        
End Sub
 
hi pmtc
change
Rows("C:T").Select
to
Range(Rows(C), Rows(T)).Select

happy friday
;-)
it all starts tomorrow!! If a man says something and there are no women there to hear him, is he still wrong?
 
Works great Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top