Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Simple questions (I hope)

1) In Column A:A I want to select A3: the last cell in that column with data
in it (non-empty cell).

2) On this code = [ If ActiveCell.Row < 1 Then ] I want to expand it to
If ActiveCell.Row < 1 or 2 Then. But the "or 2" is throwing things off???
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Simple questions (I hope)

1. The following will return the last row number with data and susbstitue
into the select

Dim lstrow As Long
lstrow = Sheets("WSname").Cells(Rows.Count, "A").End(xlUp).Row
Range("A" & lstrow).Select

2. You need to be explicit about the second condition eg....

If ActiveCell.Row < 1 or ActiveCell.Row < 2 Then

Cheers
Nigel

"scrabtree23" wrote in message
...
1) In Column A:A I want to select A3: the last cell in that column with

data
in it (non-empty cell).

2) On this code = [ If ActiveCell.Row < 1 Then ] I want to expand it to
If ActiveCell.Row < 1 or 2 Then. But the "or 2" is throwing things

off???


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Simple questions (I hope)

2. You need to be explicit about the second condition eg....

If ActiveCell.Row < 1 or ActiveCell.Row < 2 Then


While it is not clear what the OP means exactly by 1 or 2, I would suspect
he wants something like

If ActiveCell.Row < 1 and ActiveCell.Row < 2 then

I say this, because I would be hard pressed to come up with an activecell
that did not meet one of the conditions of not being row 1 or not being row
2 as stated using an OR connector.


If I am right, then a less explicit (but equally effective) approach might
be

if ActiveCell.Row 2 then

of
If ActiveCell.row = 3 then

--
Regards,
Tom Ogilvy


"Nigel" wrote in message
...
1. The following will return the last row number with data and susbstitue
into the select

Dim lstrow As Long
lstrow = Sheets("WSname").Cells(Rows.Count, "A").End(xlUp).Row
Range("A" & lstrow).Select

2. You need to be explicit about the second condition eg....

If ActiveCell.Row < 1 or ActiveCell.Row < 2 Then

Cheers
Nigel

"scrabtree23" wrote in message
...
1) In Column A:A I want to select A3: the last cell in that column with

data
in it (non-empty cell).

2) On this code = [ If ActiveCell.Row < 1 Then ] I want to expand it

to
If ActiveCell.Row < 1 or 2 Then. But the "or 2" is throwing things

off???




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default Simple questions (I hope)

First and second condition must be explicit. based on
your code, I believe what u are trying to achieve should
be done using the and operator -- meaning check this
condition and this condition.

Try this

If ActiveCell.Row < 1 And ActiveCell.Row < 2 Then



-----Original Message-----
1) In Column A:A I want to select A3: the last cell in

that column with data
in it (non-empty cell).

2) On this code = [ If ActiveCell.Row < 1 Then ] I

want to expand it to
If ActiveCell.Row < 1 or 2 Then. But the "or 2" is

throwing things off???
.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Simple questions (I hope)

Of course you are right Tom, I had not looked at the logic more the explicit
condition.

The OP will no doubt benefit.

Cheers
Nigel

"Tom Ogilvy" wrote in message
...
2. You need to be explicit about the second condition eg....


If ActiveCell.Row < 1 or ActiveCell.Row < 2 Then


While it is not clear what the OP means exactly by 1 or 2, I would suspect
he wants something like

If ActiveCell.Row < 1 and ActiveCell.Row < 2 then

I say this, because I would be hard pressed to come up with an activecell
that did not meet one of the conditions of not being row 1 or not being

row
2 as stated using an OR connector.


If I am right, then a less explicit (but equally effective) approach might
be

if ActiveCell.Row 2 then

of
If ActiveCell.row = 3 then

--
Regards,
Tom Ogilvy


"Nigel" wrote in message
...
1. The following will return the last row number with data and

susbstitue
into the select

Dim lstrow As Long
lstrow = Sheets("WSname").Cells(Rows.Count, "A").End(xlUp).Row
Range("A" & lstrow).Select

2. You need to be explicit about the second condition eg....

If ActiveCell.Row < 1 or ActiveCell.Row < 2 Then

Cheers
Nigel

"scrabtree23" wrote in message
...
1) In Column A:A I want to select A3: the last cell in that column

with
data
in it (non-empty cell).

2) On this code = [ If ActiveCell.Row < 1 Then ] I want to expand

it
to
If ActiveCell.Row < 1 or 2 Then. But the "or 2" is throwing things

off???








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Simple questions (I hope)

The answer to question 2 works great. Here is what I did with your answer to
question 1. Where is my mistake? I want it to copy everything from B3: the
last cell in Column B:B that is not blank???

Dim Istrow As Long
Istrow = Sheets("Sheet1").Cells(Rows.Count, "B:B").End(xlUp).Row
Range("B3" & Istrow).Copy

"Nigel" wrote:

1. The following will return the last row number with data and susbstitue
into the select

Dim lstrow As Long
lstrow = Sheets("WSname").Cells(Rows.Count, "A").End(xlUp).Row
Range("A" & lstrow).Select

2. You need to be explicit about the second condition eg....

If ActiveCell.Row < 1 or ActiveCell.Row < 2 Then

Cheers
Nigel

"scrabtree23" wrote in message
...
1) In Column A:A I want to select A3: the last cell in that column with

data
in it (non-empty cell).

2) On this code = [ If ActiveCell.Row < 1 Then ] I want to expand it to
If ActiveCell.Row < 1 or 2 Then. But the "or 2" is throwing things

off???



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Simple questions (I hope)

I altered my logic and made this work. The explicit was the issue I was
struggling with. What about an answer to my question 1?

"Tom Ogilvy" wrote:

2. You need to be explicit about the second condition eg....


If ActiveCell.Row < 1 or ActiveCell.Row < 2 Then


While it is not clear what the OP means exactly by 1 or 2, I would suspect
he wants something like

If ActiveCell.Row < 1 and ActiveCell.Row < 2 then

I say this, because I would be hard pressed to come up with an activecell
that did not meet one of the conditions of not being row 1 or not being row
2 as stated using an OR connector.


If I am right, then a less explicit (but equally effective) approach might
be

if ActiveCell.Row 2 then

of
If ActiveCell.row = 3 then

--
Regards,
Tom Ogilvy


"Nigel" wrote in message
...
1. The following will return the last row number with data and susbstitue
into the select

Dim lstrow As Long
lstrow = Sheets("WSname").Cells(Rows.Count, "A").End(xlUp).Row
Range("A" & lstrow).Select

2. You need to be explicit about the second condition eg....

If ActiveCell.Row < 1 or ActiveCell.Row < 2 Then

Cheers
Nigel

"scrabtree23" wrote in message
...
1) In Column A:A I want to select A3: the last cell in that column with

data
in it (non-empty cell).

2) On this code = [ If ActiveCell.Row < 1 Then ] I want to expand it

to
If ActiveCell.Row < 1 or 2 Then. But the "or 2" is throwing things

off???





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Simple questions (I hope)

Try.....


Dim Istrow As Long
Istrow = Sheets("Sheet1").Cells(Rows.Count, "B").End(xlUp).Row
Range("B3:B" & Istrow).Copy

Cheers
Nigel

"scrabtree23" wrote in message
...
The answer to question 2 works great. Here is what I did with your answer

to
question 1. Where is my mistake? I want it to copy everything from B3:

the
last cell in Column B:B that is not blank???

Dim Istrow As Long
Istrow = Sheets("Sheet1").Cells(Rows.Count, "B:B").End(xlUp).Row
Range("B3" & Istrow).Copy

"Nigel" wrote:

1. The following will return the last row number with data and

susbstitue
into the select

Dim lstrow As Long
lstrow = Sheets("WSname").Cells(Rows.Count, "A").End(xlUp).Row
Range("A" & lstrow).Select

2. You need to be explicit about the second condition eg....

If ActiveCell.Row < 1 or ActiveCell.Row < 2 Then

Cheers
Nigel

"scrabtree23" wrote in message
...
1) In Column A:A I want to select A3: the last cell in that column

with
data
in it (non-empty cell).

2) On this code = [ If ActiveCell.Row < 1 Then ] I want to expand

it to
If ActiveCell.Row < 1 or 2 Then. But the "or 2" is throwing things

off???





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
Simple Formula Questions (I hope) Logues New Users to Excel 5 May 28th 09 05:36 AM
Simple one I hope???? Kev Excel Discussion (Misc queries) 2 May 10th 07 02:06 PM
Questions should be simple please help babiigirl Excel Worksheet Functions 3 June 14th 06 07:24 PM
Newby questions - simple (I hope) Nooby Excel Discussion (Misc queries) 1 March 8th 06 05:04 PM
Several simple questions Stuart[_5_] Excel Programming 1 September 14th 03 08:58 PM


All times are GMT +1. The time now is 08:14 AM.

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"