Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Left hanging

The following code was kindly supplied to me but it fails to run, in fact it
hangs. Anyone know what might be wrong with it.

Private Sub CommandButton1_Click()
Dim rng As Range, lastrow As Long
lastrow = Cells(Rows.Count, 4).End(xlUp).Row
Set rng = Range("D1")
Do While UCase(rng) < "G" And rng.Row <= lastrow
rng = rng.Offset(1, 0)
Loop
If UCase(rng.Value) = "G" Then
rng.EntireRow.Insert
End If

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Left hanging

Hi Pat,

Try changing:

rng = rng.Offset(1, 0)



to:

Set rng = rng.Offset(1, 0)

---
Regards,
Norman



"Pat" wrote in message
...
The following code was kindly supplied to me but it fails to run, in fact
it
hangs. Anyone know what might be wrong with it.

Private Sub CommandButton1_Click()
Dim rng As Range, lastrow As Long
lastrow = Cells(Rows.Count, 4).End(xlUp).Row
Set rng = Range("D1")
Do While UCase(rng) < "G" And rng.Row <= lastrow
rng = rng.Offset(1, 0)
Loop
If UCase(rng.Value) = "G" Then
rng.EntireRow.Insert
End If

End Sub




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
selection hanging selection hanging New Users to Excel 2 June 2nd 09 02:41 PM
Excel hanging... Jambo Excel Discussion (Misc queries) 1 May 30th 08 03:13 PM
Macro hanging up on 2nd use and later. Dave H Excel Discussion (Misc queries) 2 May 25th 06 01:57 PM
Excel hanging up Dave Peterson[_3_] Excel Programming 0 September 9th 04 07:10 PM
Hanging Instances Of EXCEL.EXE? MDW Excel Programming 1 July 9th 04 03:27 PM


All times are GMT +1. The time now is 01:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"