I'm revisiting this and have come up with the following:
Code:
--------------------
Option Explicit
Sub INSERT_SPACES_TXTBOX()
Dim LastRow As Range
Dim Rng As Range
Dim i As Long
On Error Resume Next
Set Rng = Application.InputBox("Select column with mouse", Type:=8)
On Error GoTo 0
If Rng Is Nothing Then
MsgBox "You cancelled"
Exit Sub
End If
'Rng.EntireColumn.Select
'MsgBox "You selected " & Rng.EntireColumn.Address(0, 0)
Dim strfirst As String
Dim strletter As String
strfirst = IIf(Chr$(64 + Rng.Column \ 26) = "@", "", Chr(64 + Rng.Column \ 26))
strletter = strfirst & Chr$(64 + Rng.Column Mod 26)
'MsgBox strletter
LastRow = Range(strletter & "65536").End(xlUp).Row
For i = LastRow To 2 Step -1
If Range(strletter & i).Value < Range(strletter & i - 1).Value Then
Range(strletter & i).EntireRow.Insert
End If
Next
Rows("2:2").Select
Range("A2").Activate
Selection.Interior.ColorIndex = xlNone
End Sub
--------------------
Problem is that its stopping at this code here
Code:
--------------------
LastRow = Range(strletter & "65536").End(xlUp).Row
--------------------
and giving me the following:
"Object variable or With block variable not set"
Any clues or hints?
One other thing, is there an easier way to write this?
--
DKY
------------------------------------------------------------------------
DKY's Profile:
http://www.excelforum.com/member.php...o&userid=14515
View this thread:
http://www.excelforum.com/showthread...hreadid=385000