Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Select range from ActiveCell do to Lastcell

From Leith Ross 2/7/2006

Dim EndCell As Range
Set EndCell = ActiveSheet.Cells(Rows.Count, "A").End(xlUp)
ActiveSheet.Range(ActiveCell, EndCell).ClearContents

If I change the A to an N it selects a range from ActiveCell down to last
entry in Column N.
My ActiveCell is in Column A but Column N may not have data down to the
last cell as in Column A

How do I select a range of cells from an ActiveCell in column A across to
Column N and down to last data cell in column A

--
Thank you

Aussie Bob C
Little cost to carry knowledge with you.
Win XP P3 Office 2007 on Mini Mac using VMware.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Select range from ActiveCell do to Lastcell

Hi,

Try this with the usual caveat that it is very unlikely you need to select
the range to do what you want. The last line could simply be

MyRangeA.ClearContents


Dim MyRangeA As Range
Dim LastRowA As Long
LastRowA = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRangeA = Range("A" & ActiveCell.Row & ":N" & LastRowA)
MyRangeA.Select
--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Aussie Bob C" wrote:

From Leith Ross 2/7/2006

Dim EndCell As Range
Set EndCell = ActiveSheet.Cells(Rows.Count, "A").End(xlUp)
ActiveSheet.Range(ActiveCell, EndCell).ClearContents

If I change the A to an N it selects a range from ActiveCell down to last
entry in Column N.
My ActiveCell is in Column A but Column N may not have data down to the
last cell as in Column A

How do I select a range of cells from an ActiveCell in column A across to
Column N and down to last data cell in column A

--
Thank you

Aussie Bob C
Little cost to carry knowledge with you.
Win XP P3 Office 2007 on Mini Mac using VMware.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Select range from ActiveCell do to Lastcell


Dim EndCell As Range
Dim FirstRow as Integer
Dim LastRow as Integer
FirstRow = ActiveSheet.ActiveCell.Row
LastRow ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row

Set DataRange = ActiveSheet.Range("N" & FirstRow & ":N" & LastRow)
DataRange.ClearContents


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=186589

Excel Live Chat

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Select range from ActiveCell do to Lastcell

Hello Aussie Bob,

Whether you use the If/Else/EndIf is up to you but I should think that you
would not want code selecting the range if you have not previously selected a
cell in the correct column.

Having said that, normally with code it is not necessary to actually select
ranges but not knowing what you are doing with the code it is hard to advise
the best way for your particular case.

Sub SelectSpecific()

Dim lastRow As Long

With ActiveSheet
If ActiveCell.Column = Columns("A").Column Then
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range(ActiveCell, .Cells(lastRow, "N")).Select
Else
MsgBox "Activecell not in column A"
End If
End With

End Sub


--
Regards,

OssieMac


"Aussie Bob C" wrote:

From Leith Ross 2/7/2006

Dim EndCell As Range
Set EndCell = ActiveSheet.Cells(Rows.Count, "A").End(xlUp)
ActiveSheet.Range(ActiveCell, EndCell).ClearContents

If I change the A to an N it selects a range from ActiveCell down to last
entry in Column N.
My ActiveCell is in Column A but Column N may not have data down to the
last cell as in Column A

How do I select a range of cells from an ActiveCell in column A across to
Column N and down to last data cell in column A

--
Thank you

Aussie Bob C
Little cost to carry knowledge with you.
Win XP P3 Office 2007 on Mini Mac using VMware.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Select range from ActiveCell do to Lastcell

Hi OssieMac

Thanks for the code with the If/Else/Endif safety added.
Just what I needed.

--
Thank you

Aussie Bob C
Little cost to carry knowledge with you.
Win XP P3 Office 2007 on Mini Mac using VMware.


"OssieMac" wrote:

Hello Aussie Bob,

Whether you use the If/Else/EndIf is up to you but I should think that you
would not want code selecting the range if you have not previously selected a
cell in the correct column.

Having said that, normally with code it is not necessary to actually select
ranges but not knowing what you are doing with the code it is hard to advise
the best way for your particular case.

Sub SelectSpecific()

Dim lastRow As Long

With ActiveSheet
If ActiveCell.Column = Columns("A").Column Then
lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range(ActiveCell, .Cells(lastRow, "N")).Select
Else
MsgBox "Activecell not in column A"
End If
End With

End Sub


--
Regards,

OssieMac


"Aussie Bob C" wrote:

From Leith Ross 2/7/2006

Dim EndCell As Range
Set EndCell = ActiveSheet.Cells(Rows.Count, "A").End(xlUp)
ActiveSheet.Range(ActiveCell, EndCell).ClearContents

If I change the A to an N it selects a range from ActiveCell down to last
entry in Column N.
My ActiveCell is in Column A but Column N may not have data down to the
last cell as in Column A

How do I select a range of cells from an ActiveCell in column A across to
Column N and down to last data cell in column A

--
Thank you

Aussie Bob C
Little cost to carry knowledge with you.
Win XP P3 Office 2007 on Mini Mac using VMware.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 376
Default Select range from ActiveCell do to Lastcell

Hi Bob

Dim lr as long, fr as long
with activesheet
fr=activecell.row
lr = cells(Rows.count("A").End(Xlup).Row
range("A" & fr & ":N" & lr).clearcontents
end with

--
Regards
Roger Govier

Aussie Bob C wrote:
From Leith Ross 2/7/2006

Dim EndCell As Range
Set EndCell = ActiveSheet.Cells(Rows.Count, "A").End(xlUp)
ActiveSheet.Range(ActiveCell, EndCell).ClearContents

If I change the A to an N it selects a range from ActiveCell down to last
entry in Column N.
My ActiveCell is in Column A but Column N may not have data down to the
last cell as in Column A

How do I select a range of cells from an ActiveCell in column A across to
Column N and down to last data cell in column A

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Select range from ActiveCell do to Lastcell

This should do it:

Sub test()
Dim EndCell As Range
Set EndCell = Cells(ActiveSheet.Cells(Rows.Count, "A").End(xlUp), "N")
ActiveSheet.Range(ActiveCell, EndCell).ClearContents
End Sub

Mike F
"Aussie Bob C" wrote in message
...
From Leith Ross 2/7/2006

Dim EndCell As Range
Set EndCell = ActiveSheet.Cells(Rows.Count, "A").End(xlUp)
ActiveSheet.Range(ActiveCell, EndCell).ClearContents

If I change the A to an N it selects a range from ActiveCell down to last
entry in Column N.
My ActiveCell is in Column A but Column N may not have data down to the
last cell as in Column A

How do I select a range of cells from an ActiveCell in column A across to
Column N and down to last data cell in column A

--
Thank you

Aussie Bob C
Little cost to carry knowledge with you.
Win XP P3 Office 2007 on Mini Mac using VMware.



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
Select range of cells in column AS based upon lastcell in col A. jonnybrovo815 Excel Programming 2 November 19th 09 05:21 PM
Select ActiveCell Range Tanya Excel Programming 3 May 26th 07 01:36 AM
ActiveCell.Row in Range().Select? thebluerider Excel Programming 1 August 19th 06 11:40 AM
select range next to activecell lookin Excel Programming 3 March 29th 06 07:56 PM
Select Activecell in Range PraxisPete Excel Programming 0 June 1st 05 01:23 PM


All times are GMT +1. The time now is 05:42 PM.

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

About Us

"It's about Microsoft Excel"