Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Ayden Smith   on Sep 30 In MS Office Category.

  
Question Answered By: Finn Jones   on Sep 30

Sub NumberRows()
Dim rRange As Range
Dim sPrompt, sTitle As String
Dim lRangeCount As Long
Dim lColumn As Long
Dim sRange As String
Dim l As Long

'Makes Input Box setup easier to read
sPrompt = "Enter some text for your input box"
sTitle = "A title for input box"
On Error Resume Next
Set rRange = Application.InputBox(Prompt:=sPrompt, Title:=sTitle, _
Default:=ActiveCell.Address, Type:=8)
If Err.Number = 424 Then 'In case user hits the cancel button.
Resume 0
Exit Sub
End If
Resume 0

sRange = rRange.Address
Range(sRange).Select
Set rRange = Application.ActiveCell
sRange = rRange.Address
Range(sRange).Select
ActiveCell.Offset(0, 1).Select
ActiveCell.EntireColumn.Insert Shift:=xlToRight
lColumn = rRange.Column
lRangeCount = Cells(Rows.Count, lColumn).End(xlUp).Row

For l = 1 To lRangeCount
ActiveCell.Offset(l, 0).Value = l + 1
Next

End Sub

Share: 

 

This Question has 11 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Last Row and Column Or get search suggestion and latest updates.


Tagged: