Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Code falling over

I am getting an error when rng.Select is inserted into the following code:

If IsEmpty(Range("b9")) Then
MsgBox "No record found in B9.", vbInformation
Else
lngLastRow = Cells(Rows.Count, "B").End(xlUp).Row ' + 1

If lngLastRow <= 10 Then
Range("B10").Value = Range("B9").Value
Else
Cells(lngLastRow, "B").Value = Range("B9").Value
rng.Select
End If
End If

How should this be included without the code falling over.

Thank you if you can be of help.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Code falling over

Replace:
rng.Select
with:
If rng Is Nothing Then
Else
rng.Select
End If

--
Gary''s Student - gsnu200909


"Gotroots" wrote:

I am getting an error when rng.Select is inserted into the following code:

If IsEmpty(Range("b9")) Then
MsgBox "No record found in B9.", vbInformation
Else
lngLastRow = Cells(Rows.Count, "B").End(xlUp).Row ' + 1

If lngLastRow <= 10 Then
Range("B10").Value = Range("B9").Value
Else
Cells(lngLastRow, "B").Value = Range("B9").Value
rng.Select
End If
End If

How should this be included without the code falling over.

Thank you if you can be of help.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Code falling over

Where did "rng" come from? The only place I see it is in the statement you
are asking about... did you ever Set an actual range to this variable
earlier in your code somewhere? If so, then you need to look there for your
problem; if not, then that **is** your problem.

--
Rick (MVP - Excel)


"Gotroots" wrote in message
...
I am getting an error when rng.Select is inserted into the following code:

If IsEmpty(Range("b9")) Then
MsgBox "No record found in B9.", vbInformation
Else
lngLastRow = Cells(Rows.Count, "B").End(xlUp).Row ' + 1

If lngLastRow <= 10 Then
Range("B10").Value = Range("B9").Value
Else
Cells(lngLastRow, "B").Value = Range("B9").Value
rng.Select
End If
End If

How should this be included without the code falling over.

Thank you if you can be of help.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Code falling over

You don't seem to be assigning (setting) anything to the variable "rng",
which presumably is an object variable ......


--
Time is just the thing that keeps everything from happening all at once


"Gotroots" wrote:

I am getting an error when rng.Select is inserted into the following code:

If IsEmpty(Range("b9")) Then
MsgBox "No record found in B9.", vbInformation
Else
lngLastRow = Cells(Rows.Count, "B").End(xlUp).Row ' + 1

If lngLastRow <= 10 Then
Range("B10").Value = Range("B9").Value
Else
Cells(lngLastRow, "B").Value = Range("B9").Value
rng.Select
End If
End If

How should this be included without the code falling over.

Thank you if you can be of help.

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
Application Event Procedure <Falling Over Tim Childs Excel Programming 10 June 18th 07 10:06 AM
Rising / falling points Macro Help joecrabtree Excel Programming 3 December 4th 06 05:57 PM
why is the zero falling off a zip code in excel? Pam Excel Worksheet Functions 3 September 5th 06 08:10 PM
Formula falling over in more than one cell moviegrrl Excel Worksheet Functions 5 May 25th 06 04:53 PM
Falling within a range ben simpson Excel Discussion (Misc queries) 2 March 14th 06 03:21 PM


All times are GMT +1. The time now is 07:37 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"