PC Review


Reply
Thread Tools Rate Thread

Code falling over

 
 
Gotroots
Guest
Posts: n/a
 
      17th Dec 2009
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 With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      17th Dec 2009
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.
>

 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      17th Dec 2009
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" <(E-Mail Removed)> wrote in message
news:222F3791-F699-421C-B17C-(E-Mail Removed)...
>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 With Quote
 
Neptune Dinosaur
Guest
Posts: n/a
 
      18th Dec 2009
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
XP is falling apart ?! Me__2001 Windows XP 9 8th Feb 2007 10:23 PM
why is the zero falling off a zip code in excel? =?Utf-8?B?UGFt?= Microsoft Excel Worksheet Functions 3 5th Sep 2006 08:10 PM
GPS intermediate driver - managed code sample falling over richard@binaryrefinery.com Microsoft Dot NET Compact Framework 1 23rd Sep 2005 04:45 PM
I am FALLING and I CAN'T GET UP List Freeware 2 23rd Jan 2005 09:57 PM
Help me now I'm falling Gregory Windows XP General 1 9th Jun 2004 06:58 PM


Features
 

Advertising
 

Newsgroups
 


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