Hi, I have the below VBA code that inserts a coloured row based on a
changing value in Cell 'C3' What I want to do is to have the macro let
the user input the cell ref themselves of 'Range("c3").Select' bit of
the code. How can I change the below code to help me do this?


Sub Insert_row()

Dim Number_of_rows As Long

Dim Rowinsert As Integer

Number_of_rows = Range("A65536").End(xlUp).Row

Ans = InputBox("How many rows do you want to insert ?", "Rows", 1)

If IsNumeric(Ans) Then

Rowinsert = CInt(Ans)

Else

MsgBox "Invalid number entered", vbCritical, "Error"

Exit Sub

End If

Range("c3").Select

Do Until Selection.Row = Number_of_rows + 1

If Selection.Value <> Selection.Offset(-1, 0).Value Then

Selection.EntireRow.Resize(Rowinsert).Insert

Selection.EntireRow.Interior.ColorIndex = 6#

Number_of_rows = Number_of_rows + Rowinsert

Selection.Offset(Rowinsert + 1, 0).Select


Else

Selection.Offset(1, 0).Select

End If

Loop

End Sub

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our Facebook Group @ http://www.facebook.com/group.php?gid=287779555678
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 6,800 subscribers worldwide and receive many nice notes about the 
learning and support from the group.Let friends and co-workers know they can 
subscribe to group at http://groups.google.com/group/excel-macros/subscribe

To unsubscribe from this group, send email to 
excel-macros+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.

Reply via email to